-
I've created dynamic route. Do you know what could be the reason? EDIT: it's because I was keeping initial data in react state and it kept it after route change keeping rendered same old data. Can you please comment on this? How to work with it? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
From what I read, I think the problem is that you're syncing state instead of deriving it. Have a look at Kent's blogpost about it: https://kentcdodds.com/blog/dont-sync-state-derive-it |
Beta Was this translation helpful? Give feedback.
-
I would not keep a state with the data from the loader/URL, but if for some reason you need to and you can't find a way to don't do it. You will have to run an effect to sync any change from the loader data/url back to your state, and ensure you don't overwrite unsaved changes done by the user. |
Beta Was this translation helpful? Give feedback.
I would not keep a state with the data from the loader/URL, but if for some reason you need to and you can't find a way to don't do it. You will have to run an effect to sync any change from the loader data/url back to your state, and ensure you don't overwrite unsaved changes done by the user.