UNPKG

@hitachivantara/uikit-react-core

Version:

Core React components for the NEXT Design System.

16 lines (15 loc) 376 B
import { useRef, useState } from "react"; const useComputation = (valueFn, valueFallback) => { const computed = useRef(null); const [value, setValue] = useState(valueFallback); const computeValue = () => { if (!computed.current) { setValue(valueFn?.()); computed.current = true; } }; return [value, computeValue]; }; export { useComputation };