Nice introductory article into custom hooks and destructing. This example would benefit from using useReducer rather than useState. I think you can learn all the same lessons (though we'd use an array rather than an object) and the end product would be more powerful while using less memory.
You're totally right. If a custom hook is more complex, we definitely need to re-think it with useReducer.
Here we have a state and two methods (three with your example and the reset method).. but if the custom hook has x methods better to switch to the useReducer approach.
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.
Nice introductory article into custom hooks and destructing. This example would benefit from using useReducer rather than useState. I think you can learn all the same lessons (though we'd use an array rather than an object) and the end product would be more powerful while using less memory.
I did a quick example 😊
You're totally right. If a custom hook is more complex, we definitely need to re-think it with useReducer.
Here we have a state and two methods (three with your example and the reset method).. but if the custom hook has x methods better to switch to the useReducer approach.