Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

usecallback vs usememo

useCallback and useMemo -
  
  both for optimization in react.
  
useCallback - caches a callback (function) to keep its previous reference.
            - referential equality between renders
            - if function is passed as props, will not re-render the component if wrapped with react.memo
            - since function reference did not change


useMemo     - similar to useCallback but this hook caches a value or result
		    - does no recompute if dependency array did not change resulting to optimized performance
            
 
PREVIOUS NEXT
Tagged: #usecallback #usememo
ADD COMMENT
Topic
Name
7+6 =