Abu Sayed
Musician | Singer | Lyricist | Composer | Music Producer | Web | Game | XR & Blockchain Developer
Tag Archives: useEffectuseLayoutEffect
[React newbie] Prevent redundant re-rendering when calling callbacks in useEffect(useLayoutEffect) – React Dev Feed

[React newbie] Prevent redundant re-rendering when calling callbacks in useEffect(useLayoutEffect) When passing callbacks to child components to detect their changes, you may need to call the callbacks inside useEffect or useLayoutEffect and add the callbacks into its dependency array: useLayoutEffect(() => { if(onScroll) onScroll(x, pos) // call the callback }, [x, pos, onScroll]) Enter fullscreen…