|
|
|
|
|
by jakelazaroff
1701 days ago
|
|
The problem with avoiding useCallback is that another hook will bite you: useEffect. If you need to define functions that interact with your component's state, you have to memoize them with useCallback (or useRef) to avoid a useEffect infinite loop. What's even worse is that if functions passed as props are unstable, your useEffect will run every time the parent component renders — meaning that a component can't trust functions passed into it. This is one of many reasons I think useEffect is a huge footgun, and I really wish we had a better primitive for causing side effects. |
|