dai-shi / react-hooks-global-state

[NOT MAINTAINED] Simple global state for React with Hooks API without Context API
https://www.npmjs.com/package/react-hooks-global-state
MIT License
1.1k stars 62 forks source link

global state not preserved with Fast Refresh #50

Closed miaowang closed 2 years ago

miaowang commented 4 years ago

Hi, thanks for the repo. One thing that I noticed, is that the global state is not preserved with the Fast Refresh functionality. If code changes are done, then Fast Refresh kicks in to reload the UI, but in this case the global state is not preserved as I would have used useState normally. Is there a way to fix this?

dai-shi commented 4 years ago

Hi, I think I did best for fast refresh. The examples have fast refresh enabled. (Though, it's a bit old.) You might want to separate a store file. It's not 100% same as useState anyway. Can you create a codesandbox and explain the unexpected behavior? It can be a known limitation.

dai-shi commented 2 years ago

v2 is released and closing this.