usememo

Solutions on MaxInterview for usememo by the best coders in the world

showing results for - "usememo"
Ryker
12 Nov 2017
1const memoizedResult = useMemo(() => {
2  return expensiveFunction(propA, propB);
3}, [propA, propB]);
Felicity
01 Nov 2018
1/*
2Pass a “create” function and an array of dependencies. 
3useMemo will only recompute the memoized value when one 
4of the dependencies has changed. This optimization helps 
5to avoid expensive calculations on every render.
6*/
7const memoizedValue = useMemo(() => computeExpensiveValue(a, b), [a, b]);