Video yükleniyor...

Video Yüklenemedi

Ana Sayfaya Dön

⚛️ Use callback ref functions instead of useEffect (when possible) ↓

93,875 görüntüleme • 1 yıl önce •via X (Twitter)

10 Yorum

George Moller profil fotoğrafı
George Moller1 yıl önce

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

GreLI profil fotoğrafı
GreLI1 yıl önce

There is a caveat: callback refs are re-evaluated every time they changed. So if the component rerenders (often because parent does), it's better to memoize them, until you're using React Compiler. Otherwise you can get an extra action when you're not expecting it.

George Moller profil fotoğrafı
George Moller1 yıl önce

yup, or you can move the callback function outside the components scope, that works too.

Wouter Raateland profil fotoğrafı
Wouter Raateland1 yıl önce

Be aware that `scrollIntoView` gets called with `null` when the component unmounts. This version will error. Rather use `(node: HTMLDivElement | null)` and `node?.scrollIntoView(...)`.

Basstian profil fotoğrafı
Basstian1 yıl önce

the DIV as direct child of UL is wrong

micah rich profil fotoğrafı
micah rich1 yıl önce

Oh dang this is interesting. Does this mean this can go from a client component to a server component? Also - any other examples you see often? This makes me so curious

Maksym_B profil fotoğrafı
Maksym_B1 yıl önce

@onix_react тут є гарні поради

Filip profil fotoğrafı
Filip1 yıl önce

So just do the same think as in other frameworks Finally

Pavel Romanov profil fotoğrafı
Pavel Romanov1 yıl önce

This one was catchy at first, but when you get it right things work like magic

Mohammed Arshad Hassan Abdur Rahim Imthiaz profil fotoğrafı
Mohammed Arshad Hassan Abdur Rahim Imthiaz1 yıl önce

cool

Benzer Videolar