Skip to content

Instantly share code, notes, and snippets.

@tmkasun
Created September 4, 2020 15:13
Show Gist options
  • Save tmkasun/ee304b2437b2d76fc287b79a5b5e3937 to your computer and use it in GitHub Desktop.
Save tmkasun/ee304b2437b2d76fc287b79a5b5e3937 to your computer and use it in GitHub Desktop.
Sample custom redirect
import React, { Component } from 'react';
import User from '../data/User';
import Utils from '../data/Utils';
/**
* Logout component
* @class Logout
* @extends {Component} Logout component
*/
class Logout extends Component {
/**
* Component Mounted Lifecycle call back
*
* @memberof Logout
*/
componentDidMount() {
const environmentName = Utils.getEnvironment().label;
localStorage.removeItem(`${User.CONST.LOCALSTORAGE_USER}_${environmentName}`);
if (typeof window !== 'undefined') {
window.location.href = "http://foo.com/customError";
}
}
/**
* Main render method
*
* @returns {JSX}
* @memberof Logout
*/
render() {
// https://reactjs.org/docs/jsx-in-depth.html#booleans-null-and-undefined-are-ignored
return null;
}
}
export default Logout;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment