UNPKG

877 BJavaScriptView Raw
1import { useRef, createElement } from 'react';
2
3function _extends() {
4 _extends = Object.assign || function (target) {
5 for (var i = 1; i < arguments.length; i++) {
6 var source = arguments[i];
7
8 for (var key in source) {
9 if (Object.prototype.hasOwnProperty.call(source, key)) {
10 target[key] = source[key];
11 }
12 }
13 }
14
15 return target;
16 };
17
18 return _extends.apply(this, arguments);
19}
20
21function useFC(render) {
22 var renderRef = useRef();
23 renderRef.current = render;
24 return useRef(function RenderFunctionWrapper(restProps) {
25 return renderRef.current(restProps);
26 }).current;
27}
28function useWith(Wrapped, props) {
29 return useFC(function (restProps) {
30 return /*#__PURE__*/createElement(Wrapped, _extends({}, props, restProps));
31 });
32}
33
34export default useWith;
35export { useFC };
36//# sourceMappingURL=use-with.esm.js.map