UNPKG

@nutui/nutui-react

Version:

京东风格的轻量级移动端 React 组件库,支持一套代码生成 H5 和小程序

10 lines (9 loc) 371 B
import * as React from "react"; export default function useMemo(getValue, condition, shouldUpdate) { var cacheRef = React.useRef({}); if (!('value' in cacheRef.current) || shouldUpdate(cacheRef.current.condition, condition)) { cacheRef.current.value = getValue(); cacheRef.current.condition = condition; } return cacheRef.current.value; }