Gatsby: navigate() function load the url but the page is not refreshed on mobile

Created on 24 Sep 2020  路  8Comments  路  Source: gatsbyjs/gatsby

the current url is "/abc/?tag=a" and I navigated it to "abc/?tag=b".
But the url on the browser is changed, but the page is not refreshed on mobile.

Look forward to your support.

Best

needs reproduction reacrouter and Links bug

All 8 comments

@developer0116 This doesn't sound Gatsby specific. Could you provide more details or possibly a minimal reproduction?

This appears to be a regression somewhere between gatsby 2.24.63 and 2.24.73 dealing with navigation changing only the search parameter. This applies to all browsers as far as I've seen and is not mobile specific.

On version 63, calling navigate('?p=42', { replace: true }) updates the URL search parameter and causes a component re-render. Inside the render, accessing either location.search (via gatsby's passed in location) or window.location.search shows the expected value of ?p=42

After updating to version 73, making that exact same call in the exact same way (no code changes at all), the page re-renders, but accessing location.search (via either method) returns the previous URL search value, not the newly updated one. Further calls to navigate continue to update the URL in the browser, but no further component re-renders are invoked. I'll try to put together a minimal reproduction for this.

Minimal reproduction repo:
https://github.com/hayatae/gatsby-search-param-bug

Steps to reproduce:

  1. Run npm run develop
  2. Open the page, click on the buttons to change the search param - observe no updates

See it work in an older version of gatsby:

  1. Run npm install [email protected]
  2. Run npm run develop
  3. Open the page, click the buttons, see everything update as expected when the URL changes

I have the same issue when i recall the same page with a different state: navigate('/page', { state: { newState }}).

The problem appear after upgrading gatsby to version 2.24.70, older versions work without problems.

Sorry to hear you're running into an issue. To help us best begin debugging the underlying cause, it is incredibly helpful if you're able to create a minimal reproduction. This is a simplified example of the issue that makes it clear and obvious what the issue is and how we can begin to debug it.

If you're up for it, we'd very much appreciate if you could provide a minimal reproduction and we'll be able to take another look.

Thanks for using Gatsby! 馃挏

Hi @wardpeet, i've created a minimal reproduction that show the problem.

https://github.com/doscio/gatsby-navigate-issue

The index page has a button that navigate to /counter page. On that page, everytime the button Increase counter is pressed,
the counter should increase it's value, but this is not appening on gatsby version 2.24.79.

Versions prior to 2.24.70 works without problem:

  1. Run npm install [email protected]
  2. Run gatsby develop

Everytime I click Increase counter the counter is updating correctly.

@doscio @wardpeet I've already created a minimal reproduction and posted it in the comments above: https://github.com/gatsbyjs/gatsby/issues/27020#issuecomment-706850931

You can very easily modify this same reproduction to reproduce the same issue with state not updating. Basically, no navigate functions work correctly for refreshing any query or state params on the same route after version 2.24.70.

Fixed by https://github.com/gatsbyjs/gatsby/pull/27594

Please install [email protected] and it should work again.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

benstr picture benstr  路  3Comments

rossPatton picture rossPatton  路  3Comments

dustinhorton picture dustinhorton  路  3Comments

ghost picture ghost  路  3Comments

kalinchernev picture kalinchernev  路  3Comments