react-tracked: Global State Does Not Seem To Persist Between Page Routes When using React Router.

I can’t seem to hold on to a global state value using useTrackedState(), it seems like when a React Router <Route> component is used, the state is re-initialized. This could just be an issue with my application architecture, but I’d like some feedback none the less…

Here’s an example test application from my personal GitHub repository: GitHub:react-tracked-test.

Thanks for any help you can provide.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 16 (8 by maintainers)

Most upvoted comments

ill test it right away

EDIT: alright, I tried both approaches using reducers and state and I couldn’t manage to get the state to persist

EDIT II: ive implement a purely useContext state management system and are facing the same issues

EDIT III: I tried again. and this time I put the router element on the correct place. it seems my links have defaulted to a full page reload instead of navigating in-between components which caused the state to reset. @dai-shi thank you very much for providing so much help

I tried again. and this time I put the router element on the correct place. it seems my links have defaulted to a full page reload instead of navigating in-between components which caused the state to reset. @dai-shi thank you very much for providing so much help

I tested it once more using the useState pattern as seen in example 07. ❤️ works as expected.