I had one question regarding the section of the article where you introduced the reducer pattern in order to avoid having to use state in the dependencies list of the useMemo. Is there any reason using useReducer as you have would be preferable to simply using setState(prevState => ...)?
Hi Nadia, fantastic article.
I had one question regarding the section of the article where you introduced the reducer pattern in order to avoid having to use state in the dependencies list of the
useMemo
. Is there any reason usinguseReducer
as you have would be preferable to simply usingsetState(prevState => ...)
?Ha, perfect catch @kangweichan! Just haven't though about it 😳 It will also likely work for this scenario.
I just usually use reducers when the state becomes a bit big.
I came here to ask the same thing. It does work!
Awesome article, Nadia!