📜  useMemo - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:24.590000             🧑  作者: Mango

代码示例2
/*
Pass a “create” function and an array of dependencies. 
useMemo will only recompute the memoized value when one 
of the dependencies has changed. This optimization helps 
to avoid expensive calculations on every render.
*/
const memoizedValue = useMemo(() => computeExpensiveValue(a, b), [a, b]);