UNPKG

zp-bee

Version:

zp-bee,是一款基于 Dumi,由 React + TypeScript 开发的组件库 🎉。

26 lines (22 loc) 727 B
import { useRef, useMemo } from 'react'; import { _set_components, init } from './vt'; function useOnce(factory) { for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { args[_key - 1] = arguments[_key]; } var ref = useRef(null); return useMemo(function () { return factory.apply(void 0, args); }, [ref.current]); } function useVT(fnOpts) { var deps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; var ctx = init(fnOpts, deps); var set = useOnce(function () { return function (components) { return _set_components(ctx, components); }; }); return [ctx._vtcomponents, set, ctx.ref]; } export { useVT };