DEV Community

Discussion on: πŸ”₯ React Hooks.😎

Collapse
 
dawoodxp97 profile image
Shaik Dawood

Thank you 😊.

Yes, nice suggestion. I'll make sure to update the Bad Practices of Hooks in a separate blog stay tuned for it.

The use of useEffect will depends on requirement, basically the useEffect is used to execute a particular code that needs to happen during lifecycle of the component instead of on specific user interactions or DOM events.

As in your case, I'd definitely suggest you to use useEffect for checking the user login with API. Make sure to use the side effect as "Empty Dependency Array" in useEffect. So it will run once the app completes initial Render.

Hope you've got an Idea about it.. Thank You.