Zustand by itself does not support providers and autodispose out of the box. But I have found a way to make it work without extra depenencies.
The logic is inside the zustandWithProvider function. It returns a hook that lets you access the state, and a Provider component.
I suggest to create an npm package with the zustandWithProvider utility function, because I have not found any npm package like this and it is very useful.
Closes #11
Zustand by itself does not support providers and autodispose out of the box. But I have found a way to make it work without extra depenencies.
The logic is inside the
zustandWithProvider
function. It returns a hook that lets you access the state, and a Provider component.I suggest to create an npm package with the
zustandWithProvider
utility function, because I have not found any npm package like this and it is very useful.