Video wird geladen...

Video konnte nicht geladen werden

Zur Startseite

❌ Avoid deriving state in useEffect in React, this can create multiple unnecessary render phases. ✅ Instead derive the state directly in the event handler, this way you'll have one single render phase. ↓

39,326 Aufrufe • vor 2 Jahren •via X (Twitter)

9 Kommentare

Profilbild von George Moller
George Mollervor 2 Jahren

I've been working professionally with React for more than 8 years and I compiled all my knowledge into 100+ infographics and 70+ video animations just like this one. Check them out ↓

Profilbild von Web-Dev-Codi
Web-Dev-Codivor 2 Jahren

Informative as always. Thank you

Profilbild von George Moller
George Mollervor 2 Jahren

Glad you found it informative!

Profilbild von NidhiSharma | React Dev
NidhiSharma | React Devvor 2 Jahren

Sometime overuse of useEffect cause extra re-render we should avoid useEffect where ever possible. Nice sharing.

Profilbild von joey finkel
joey finkelvor 2 Jahren

But this would only work if the state that’s being updating is supposed to be updated by an event handler. For example, a piece of state you want updated on first render would still have to be the effect, right?

Profilbild von George Moller
George Mollervor 2 Jahren

Do you have an example I can take a look? Unless you are fetching data or connecting to an external system first why would you need to update a state variable in first render?

Profilbild von Bee Network - Vietnam 🇻🇳
Bee Network - Vietnam 🇻🇳vor 2 Jahren

great

Profilbild von George Moller
George Mollervor 2 Jahren

Hey do you have an email or contact where I can send you the PP discount?

Profilbild von George Moller
George Mollervor 2 Jahren

@Setback_King 😊

Ähnliche Videos