[v6] [Bug]: Nested Routes with useRoutes losing router state

3
closed
brantian
brantian
Posted 1 month ago

[v6] [Bug]: Nested Routes with useRoutes losing router state #8122

What version of React Router are you using?

6.0.0-beta.6

Steps to Reproduce

Expected Behavior

I would expect the useLocation() call to return the browser state on the state parameter. I'm mostly interested in being able to check the referrer, or previous path, when a page is loaded.

Actual Behavior

The useLocation() call returns null on state param

timdorr
timdorr
Created 1 month ago

You're not setting any sort of state on the location you're linking to, so that value is expected to be empty. It's something you set yourself, not something provided by the browser.

brantian
brantian
Created 1 month ago

Hi @timdorr , thanks for your response. Would you please indicate to me where I can find more information on how to set this state on the location? I cant find anything that works with the useRoutes hook

timdorr
timdorr
Created 1 month ago

It's in the description for a location: https://reactrouter.com/web/api/location