UNPKG

@winglet/react-utils

Version:

React utility library providing custom hooks, higher-order components (HOCs), and utility functions to enhance React application development with improved reusability and functionality

12 lines (9 loc) 293 B
import { useRef } from 'react'; import { isFunction } from '@winglet/common-utils/filter'; const useConstant = (input) => { const ref = useRef(undefined); if (!ref.current) ref.current = isFunction(input) ? input() : input; return ref.current; }; export { useConstant };