useCallback - In 3 minutes [ and why its different from useMemo ]

preview_player
Показать описание
#reacthooks #react #javascript
Stay tuned for the rest of the React Hooks Videos
Рекомендации по теме
Комментарии
Автор

This was better than most other explanations. A big confusion I see is when people think it prevents a rerender. It does not. It merely keeps a functions referential equality the same between renders, unless a dependency changes. In your example, for ex, the child component still rerenders when you hit the other button.

jasonlough
Автор

Thanks for the explanation, very clear!

adrianhervasmartinez
Автор

my nex question is, when would you want to pass a function as a prop. Can you not simply code in such a way to prevent that? Beginner question.

Strat
Автор

too fast. hv no idea what is going on but just flashing of cursor and highlighting.

sc