Professional Documents
Culture Documents
Additional Hooks:
useReducer:
useCallBack: to memomize function to optimize performance.
const <fun-name> = useCallback(()=>{<fun-body>},[dependancy])
useMemo: top optimize computations. The useMemo Hook only runs when one of
its dependencies update.
NOTE: use only as needed for expensive calculations
cmd: const expensiveCount = useMemo(()=>{return count**2;},[count])
useRef:
--Does Not Cause Re-renders,
If we tried to count how many times our application renders using the
useState Hook,
we would be caught in an infinite loop since this Hook itself causes a
re-render.
To avoid this, we can use the useRef Hook.
function App() {
const inputElement = useRef();
return (
<>
<input type="text" ref={inputElement} />
<button onClick={focusInput}>Focus
Input</button>
</>
);
}
useImperativeHandle:
cmd: useImperativeHandle(ref, createHandle, [deps])
useLayoutEffect:
useDebugValue:
Resources:
https://stackoverflow.com/questions/57005663/when-to-use-useimperativehandle-
uselayouteffect-and-usedebugvalue