I get the error in the title in code below, how do I fix it?
- Any help is appreciated!
import { useHistory } from "react-router-dom";
let history = useHistory();
history.push({
pathname: '/otherPage',
state: { detail: id }
});
//otherPage
import React, { useEffect } from 'react';
import { useLocation } from "react-router-dom";
const location = useLocation();
useEffect(() => {
console.log(location.state.detail);
}, [location]);