question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using navigate() function with a state change doesn't rerender the page

See original GitHub issue

Description

Calling the same page with a state change navigate('/page', { state: { newState }}) doesn’t cause the page to rerender. Downgrading gatsby to version 2.24.69 fix the issue and the page is rerendered correctly.

Steps to reproduce

I’ve create 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.85.

Versions prior to 2.24.70 works without problem:

  1. Run npm install gatsby@2.24.69
  2. Run gatsby develop

Everytime I click Increase counter the counter is updating correctly.

Expected result

Everytime the button Increase counter is pressed the counter value should update it’s value.

Actual result

Nothing appens when i click the button Increase counter. If i refresh the page manually (F5) the counter show the correct value.

Environment

  System:
    OS: Windows Server 2016 10.0.14393
    CPU: (8) x64 Intel(R) Core(TM) i5-8250U CPU @ 1.60GHz
  Binaries:
    Node: 14.4.0 - C:\Program Files\nodejs\node.EXE
    npm: 6.14.8 - C:\Program Files\nodejs\npm.CMD
  Languages:
    Python: 3.9.0
  Browsers: {}
  npmPackages:
    gatsby: ^2.24.85 => 2.24.85
  npmGlobalPackages:
    gatsby-cli: 2.12.109

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:5
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
WillMaygercommented, Nov 23, 2020

Hi @vladar & @doscio, Sorry for the slow response - happy to take a look into this one 😃.

0reactions
WillMaygercommented, Nov 28, 2020

Hi @vladar 👋 I have created a PR with a fix for this issue at https://github.com/gatsbyjs/gatsby/pull/28346 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Navigate from react-dom doesn't re-render the entire page
I am using a ternary condition to do this with fragments because i want to display multiple items. When i login, the url...
Read more >
React Navigation re-render / reset previous page's state on ...
Problem statement: In a react native mobile app, when a user navigates “to” or “back” from one page to another, I want to...
Read more >
When does React re-render components? - Felix Gerschau
Changing the state means that React triggers an update when we call the setState function (in React hooks, you would use useState )....
Read more >
Learn how to force react components to rerender without ...
A complete guide on component re-rendering. Here you will learn how to force react components to rerender without calling the set state.
Read more >
Navigation prop reference
Alternatively, as screen A is the top of the stack, you can use navigation.popToTop() . reset ​. The reset method lets us replace...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found