I'm using useHistory to route my website from page A
const history = useHistory();
history.push('/this/is/page-b', { object: selectedObject });
and in page B, I have:
const history = useHistory();
const objectData = history.location?.state?.object as Object;
- First question: Is there anything wrong with this code? Trying to pass data using history.
- Second question: Any suggestion for another solution to pass data instead of via useHistory hook? Just need some keywords. Thank guys.