SSG Dynamic route doesnt reset state on route change #14786
Unanswered
danilockthar
asked this question in
Help
Replies: 1 comment
-
It's possible that React is not re-rendering your page component from scratch when you change the URL. For instance, this:
will update with the different products based on the new URL. But, in react's mind, it's the "same" component, so any previous state will still be around. If this is the issue, you can fix it by adding a
By doing this, you're telling React that |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, im making SSG dynamic routes with getstaticpath and getstaticprops. But im not getting fully reset of state when i change url on client side.
The "x1" product items and the border color are persisting even in urlchange. That info comes from an state that i set when page init then change when i click and add more quantity. The expected is to restart all the page and states on route url changes.
const [prods, setProds] = useState(data.products)
what could be wrong ?
Beta Was this translation helpful? Give feedback.
All reactions