I was following a tutorial until I got this error. I know that this is caused by some changes on react-router-dom, but I have no idea of how to change this code to the new version, can you give me any suggestions?
import React, { Component } from "react";
import { withRouter } from "react-router";
const parseJwt = (token) => {
try {
return JSON.parse(atob(token.split('.')[1]));
} catch (e) {
return null;
}
};
class AuthVerify extends Component {
constructor(props) {
super(props);
props.history.listen(() => {
const user = JSON.parse(localStorage.getItem("user"));
if (user) {
const decodedJwt = parseJwt(user.accessToken);
if (decodedJwt.exp * 1000 < Date.now()) {
props.logOut();
}
}
});
}
render() {
return <div></div>;
}
}
export default withRouter(AuthVerify);