-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
State not passed between pages when using "navigate" or "<Link>" #9091
Comments
Update: I just found the state data located at: window.history.state I will close the issue in a few days to give anyone time to correct me if I'm doing this wrong. Cheers, Alex |
Try the location, as explained here: |
Thanks for the response. I just tested by logging the So perhaps accessing the state data via Cheers, Alex |
Alec, |
Just spent hours trying to get this working 😅 Glad I found this |
It's funny that I ended up here after example from Gatsby documentation didn't work https://www.gatsbyjs.com/docs/gatsby-link/#how-to-use-the-navigate-helper-function |
componentDidMount solves it |
In my case, neither in window.history.state nor location (trying with both reach router and gatsby) the state is to be found. Someone have the same problem ? |
I'm having mostly the same problem. Regardless of passing the state via
It's more or less 50% of the time I have the correct state in the |
I get a similar output |
I had a similar issue e.g. I got the I was using an onClick event on an Anchor - turns out the problem was the <a href="#" onClick={ () => navigate('/here', { state: { foo: 'bar' } } ) }>Forgot Password?</a> Removing that, fixed the issue. <a className="link" onClick={ () => navigate('/here', { state: { foo: 'bar' } } ) }>Forgot Password?</a> |
In my case, the problem was that I was trying to navigate to a subroute (Ex. '/app/home'). |
I have the same issue. I moved a page into a subdirectory and the state stopped working. Moving it back has fixed this. |
Hi all,
I have been unsuccessful in my attempts to pass the state between pages in my Gatsby v2 application.
Here is my attempt using the "Link" component:
On my "text-editor" page I run:
Unfortunately the object logged to the console is a blank object.
I then tried to use the "navigate" method instead:
But unfortunately the object logged to the console is a blank object again.
Is anyone else experiencing this issue? I'm using: gatsby@2.0.22
Cheers,
Alex
The text was updated successfully, but these errors were encountered: