Mastering useEffect: What Goes In Dependency Arrays

preview_player
Показать описание
What goes in React 18 dependency arrays for useEffect so that you don't crash your NextJS 13, Create React App or Remix application.

#shorts
Рекомендации по теме
Комментарии
Автор

I'm really amazed by how well ESLint works for useEffect and other hooks 👌

codinginflow
Автор

I'm subscribed 3 months ago and I just say, where you had been all my life 😂 I love the way you explain and you content it's really helpful ❤

nicolasmayorga
Автор

Problem with people is they know React but not enough JavaScript and its execution model.

ManvendraSK
Автор

Dang. I just disabled that rule yesterday. I will now go revise 😅 haha thanks!

P_Salazar
Автор

There is a scenario that I sometimes have to disable the rule .. when I just want to run the useffect in the mount ([]).
The rule keeps insisting to have the variables...but I know that I don't want to

sxta
Автор

What if for example we use a zustand store with function used in useEffect? ESLint always told me to get ‘‘em inside the dependency array but actually if I do, it will enter an infinite loop. Does zustand function has to be outside of useEffect, or disable next line is the correct way?

vincentcottalorda
Автор

Sometimes you need something that should not trigger an effect run when it changes, rarely but it exists 😉

Stoney_Eagle
Автор

The funny thing is, if I use the "setState" function from some "useState", then ESLint wants me to put that into the dependency array as well. Do I need to? Or should I not be setting state inside a useEffect?

justine_chang
Автор

The most annoying part with useEffect is fetching data and transforming the component state with it and you are using eslint with exhaustive-deps rule. Can you shed some light for this on how to really use useEffect?

deamorta
welcome to shbcf.ru