Skip to content

Convert to Zustand state management#97

Open
rod-glover wants to merge 20 commits into
masterfrom
try-zustand
Open

Convert to Zustand state management#97
rod-glover wants to merge 20 commits into
masterfrom
try-zustand

Conversation

@rod-glover
Copy link
Copy Markdown
Collaborator

This was very instructive, and successful. Thoughts, comments, notes:

  • With Zustand, you move all your state-related logic into the store. Advantages:
    • All state logic (actions) is right next to state definitions.
    • State logic can easily use other parts of state logic, because it too is right there.
    • Components do not need to track detailed state logic or changes to it, only changes to the actions API (action functions and their signatures). This simplifies components.
    • State logic is easy to reuse across components: just get it out of the store.
    • It imposes a certain discipline on the conception and use of state. Bad state management becomes much more obvious, and more obvious how to fix. Meanwhile components just subscribe to the parts of it they naturally need.
  • Note how computed values, such as isConfigLoaded is used: const isConfigLoaded = useStore(state => state.isConfigLoaded());
  • Config is folded naturally into the notion of state, and state logic actions can and do use it.
  • This project did not contain egregious prop drilling, but Zustand still results in a noticeable simplification of all the components that use state (directly or via props).
  • IMO, components have become slightly to moderately easier to understand, due in part to the segregation of state logic to the store.

@rod-glover
Copy link
Copy Markdown
Collaborator Author

Bug: When selecting Tmax, map spinner appears apparently forever. True for all datasets. Other variables work as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant