A better way of initializing a Zustand store with props from React.
- Make initial data for your Zustand store available through a React context.
- Create 2 hooks for accessing your Zustand store. One for accessing the raw Zustand store, and another that is a React hook.
- In this react hook, access the initial data from React context, and replace the state in the Zustand store with the initial data.
- You can still access the raw Zustand store from non-React code.
- Potential TypeError if you access Zustand through custom hook outside of the Provider.
- Create the Zustand store with the initial data, and store it in a React state.
- Make the Zustand store available through a React context.
- Access store through the React context.