If I do something like this in an onClick handler:
navigate('/some/route', {state: {foo: 'bar'}})
I can access foo
in the component that mounts at /some/route
like so:
const location = useLocation()
const {foo} = location.state
However,
foo
is undefined if I do this:
navigate(-1, {state: {foo: 'bar'}})
The problem is that I need to use navigate(-1)
for a custom back button, and I need to pass that state to know that the back button was clicked. Is there a way to pass state when value of the to
param is -1
Thank you.