Interesting to use the useEffect hook aswell, though you can also create a function that combines calling the store.set and state set. Not sure which yet which i’d prefer.
What’s your thoughts on using context, instead of useState? useState and store provide a similar function but with context it becomes something that can be shared, which would address the case of having multiple consumers of the state, each updating accordingly when the storage is updated.
Perhaps a refactoring for when the need arises.
Yeah! Before I wrote this article, I actually wasn't using useEffect at all! And I was just invoking whenever the setter was invoked: github.com/mcrowder65/mooks/commit...
Context is great, but underneath, it would still need to do useState. I would be happy to provide an example on how to do useContext.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Interesting to use the useEffect hook aswell, though you can also create a function that combines calling the store.set and state set. Not sure which yet which i’d prefer.
What’s your thoughts on using context, instead of useState? useState and store provide a similar function but with context it becomes something that can be shared, which would address the case of having multiple consumers of the state, each updating accordingly when the storage is updated.
Perhaps a refactoring for when the need arises.
Yeah! Before I wrote this article, I actually wasn't using useEffect at all! And I was just invoking whenever the setter was invoked: github.com/mcrowder65/mooks/commit...
Context is great, but underneath, it would still need to do useState. I would be happy to provide an example on how to do useContext.