DEV Community

Discussion on: useReducer instead of useState while calling APIs!

Collapse
 
yukiyohure profile image
Yuki Shibata

Thank you for the awesome post!
This makes my understanding of the useReducer deepen.

I've wondered that Is that a usual way to define an API-call function IN the useEffect hooks??

Collapse
 
hey_yogini profile image
Yogini Bende

If you don't need to use it outside the hook, there is no harm in declaring it inside. The only purpose of declaring a function there is to enable async-await. But again.. its our choice 😇

Collapse
 
yukiyohure profile image
Yuki Shibata

That makes sense!
Thank you for answering🙌

Some comments have been hidden by the post's author - find out more