paint-brush
How to Take Full Advantage of useEffect in Reactby@huzaima
954 reads
954 reads

How to Take Full Advantage of useEffect in React

by 8mDecember 12th, 2022
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Optimizing `useEffect` in React gives you a significant boost in performance and sometimes gets your code rid of nasty bugs. Here I'll discuss a few of the optimization patterns which are very easy to adhere to yet very effective. Use primitives in the dependency array instead of objects in the useEffect` dependency array. Sometimes it makes more sense to destructure the JavaScript object and only pass the specific value to the dependency. Avoid needless dependencies like using a closure to get the correct value of a new state.

People Mentioned

Mention Thumbnail

Companies Mentioned

Mention Thumbnail
Mention Thumbnail
featured image - How to Take Full Advantage of useEffect in React
undefined HackerNoon profile picture

@huzaima

L O A D I N G
. . . comments & more!

About Author

undefined HackerNoon profile picture
@huzaima

TOPICS

THIS ARTICLE WAS FEATURED IN...

Permanent on Arweave
Read on Terminal Reader
Read this story in a terminal
 Terminal
Read this story w/o Javascript
Read this story w/o Javascript
 Lite