Mastering useEffect: Avoid Using useEffect!

preview_player
Показать описание
The most import rule with useEffect is to only use it when you really need it. This will greatly simplify your code and make it easier to maintain. Building maintainable codebases in React 18, NextJS or Remix is critical.

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

Would be nice to explain why useEffect should be avoided

v.florio
Автор

I guide you to the treasure that I myself can't possess

tkdevlop
Автор

an even better example is to use <a>'s href

emmo
Автор

By the way, I really follow from top to bottom. You are a really great tutor. Teachers like you deserve great reach and applaud. It's strike to the point and most important is easy to understand the use of simple language so a person from not heavily English-speaking country can also understand you.
Love and Respect from Nepal.

aryandhakal
Автор

Love these shorts - perfect for picking up tidbits while I'm out and about

Crevulus
Автор

I have learned a lot from you. Thank you

ozzolim
Автор

David Khourshid has a whole talk on this that's unmissable

avneet
Автор

Couldn’t agree with this one more. I’ve worked on so many convoluted code based where it’s a treasure hunt to find out what’s actually happening when some event triggers. Cringed hard in my last project where one of the “senior” devs had chained useEffects throughout the app

meh
Автор

use Effect and callbacks or event handlers are side effects on a pure function. That's what most React developers don't get. They are ways to introduce side effects inside a pure system. One reacts to state, the other reacts to user input. Decide and chose.

PaulSebastianM
Автор

man where is this video before 3 months oh when you have a programmer in team do not know any thing but boss love it.

tbigqhb
Автор

Good one. But don't forget to wrap your function around useCallback hook so it won't be recreated every re render

oscardasilva
Автор

What about the initial fetch? The fetch will no longer trigger when the component first renders.

kazz
Автор

Only two use cases that are left are updating a component's state when its props change or running some code only when at the first run

yassinesafraoui
Автор

Hello, thank you for your short sharing videos. May I ask you what theme are you using in those short videos? It looks so good

LocTran-snmp
Автор

This is good, could you show more examples?

waleedsharif
Автор

I mostly use it for umbrellas unrelated side effects or something on mount

sc
Автор

What if someone needs to auto-fetch data while rendering the screen? What you are doing is fetching the URL after the button is pressed right? So in the first cycle of component mount the URL won't be fetched right?

aryandhakal
Автор

I tried it but if you set a state and accordingly fetch the state gets updated later and function gets executed first

JethiyaChampakGada
Автор

How will the component be rerendered after the data is fetched then? Maybe there is something I'm not understanding well.

YusufSalahAdDin
Автор

Please explain how will you re-render the component without useEffect on changing url in the example shared above?

itsanuragjoshi