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

17 lines (13 loc) 371 B
'use strict'; var react = require('react'); var filter = require('@winglet/common-utils/filter'); const useConstant = (input) => { const ref = react.useRef(undefined); if (!ref.current) { ref.current = { value: filter.isFunction(input) ? input() : input, }; } return ref.current.value; }; exports.useConstant = useConstant;