UNPKG

@koordinates/xstate-tree

Version:

Build UIs with Actors using xstate and React

13 lines (12 loc) 335 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.useConstant = void 0; const react_1 = require("react"); function useConstant(fn) { const ref = (0, react_1.useRef)(); if (!ref.current) { ref.current = { v: fn() }; } return ref.current.v; } exports.useConstant = useConstant;