My React app is returning :
TypeError: Cannot read property ‘accessToken’ of null when tring to open the app without accessToken in the url
componentDidMount() {
const currentComponent = this;
const webAuth = new auth0.WebAuth({
domain: 'xxx',
clientID: 'xxx',
audience: 'xxx',
scope: 'openid profile'
});
webAuth.parseHash({ hash: window.location.hash }, (err, authResult) => {
if (err) {
return console.log("error");
}
else {
webAuth.client.userInfo(authResult.accessToken, (err, user) => {
if (user) {
currentComponent.setState({
authenticated: true
})
}
})
}