enter image description here enter image description here
import * as React from 'react';
import Root from './Root';
import './App.css'
import {session} from './libs/session';
import {Redirect} from "react-router-dom";
export default class App extends React.Component {
public componentWillMount() {
console.log("componentWillMount App");
}
public componentDidMount() {
console.log("componentDidMount App");
console.log(window.location.search.replace(/\?/g,''));
const urlParmes = window.location.search.replace(/\?/g,'');
session.token = urlParmes.replace(/^token=/g,'');
}
public render() {
if (session.token === '' || session.token === null || session.token === 'undefined') {
console.log('no Jurisdiction');
return (<Redirect to='/'/>);
} else {
console.log('has Jurisdiction')
}
return (
<div className="App">
<Root />
</div>
)
}
}
My purpose is to detect 'token' and then redirect it to the login page. this is why? please help me. Thanks
The Router have to installed, I solved with the installation using the following command:
npm i react-router-dom --save
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With