DEV Community

loading...

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
ms_yogii profile image
Yogini Bende Author

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

Forem Open with the Forem app