Duplicate store for different routes #1902
-
I'm working on an app where there are various dashboard pages. We use react router for the page routes, and the number of dashboard is dynamic. Each dashboard is pretty much the same, and ideally we want a Store for each dashboard which persists the state of that page when people switch between the pages. I've got it working by combining with React Context (code extract below) but, maybe due to using React Context - every component re-renders any time any value changes - and I can't seem to select values separately. Apart from the re-render issue, it works, but I'm not sure if there's way to fix is, or if I need to find a solution that doesn't rely on React Context. If so - any pointers on the best way to dynamically create stores for each routed page?
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
@jonshutt let me create a demo for you |
Beta Was this translation helpful? Give feedback.
@jonshutt here you go -> https://codesandbox.io/p/sandbox/dazzling-dawn-9kyp45?file=%2Fsrc%2Fstores%2Fuse-counter-store.ts%3A20%2C12