In React I am trying to pass both pathname and another parameter using history.push. When it executes the application redirects to the specified page but the state is undefined so I cannot obtain the other parameter.
<Route path='/main' exact component={Main} />
import { useHistory } from "react-router-dom";
var history = useHistory();
function handleSubmit(event) {
event.preventDefault();
history.push("/main", { state: 'test'});
};
const Main= (props) => {
console.log(props.location.state);
};
export default Main;
In Main, props.location.state is undefined. Can you help me please?