Since these are mutually dependent state items, I'd use useReducer.
Or to make the code much cleaner, move all this into a separate hook that uses useReducer internally.
I agree! I mentioned in the post that I normally wound't use three separate useState calls - just wanted to illustrate the concept easily.
useState
I do something similar to what you're mentioning - which you can read about here if you're interested 👍
dev.to/farazamiruddin/opinionated-...
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
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.
Since these are mutually dependent state items, I'd use useReducer.
Or to make the code much cleaner, move all this into a separate hook that uses useReducer internally.
I agree! I mentioned in the post that I normally wound't use three separate
useState
calls - just wanted to illustrate the concept easily.I do something similar to what you're mentioning - which you can read about here if you're interested 👍
dev.to/farazamiruddin/opinionated-...