Zustand Store Creation before React
Hey,
I was wondering how you could initialise a zustand store outside of react context entirely.
Say i have
Now the only way i can initiate a DbContext is via the
DataRepository.initialize()
method.
However, i dont want my dbContext to have to be null or undefined before it's initialised.
I want dbContext to always have a value, and i dont really need/want the store to have to store the other params.
Now an easy solution outside of the react work is DI, inject the service where you need it. In this case its not really possible in react. I can create a factory to do like
However this then means i dont have the global hook anymore...
Any suggestions would be great.0 Replies