UNPKG

1.38 kBJavaScriptView Raw
1(function (global, factory) {
2 typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react')) :
3 typeof define === 'function' && define.amd ? define(['exports', 'react'], factory) :
4 (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global['use-with'] = {}, global.React));
5}(this, (function (exports, React) { 'use strict';
6
7 function _extends() {
8 _extends = Object.assign || function (target) {
9 for (var i = 1; i < arguments.length; i++) {
10 var source = arguments[i];
11
12 for (var key in source) {
13 if (Object.prototype.hasOwnProperty.call(source, key)) {
14 target[key] = source[key];
15 }
16 }
17 }
18
19 return target;
20 };
21
22 return _extends.apply(this, arguments);
23 }
24
25 function useFC(render) {
26 var renderRef = React.useRef();
27 renderRef.current = render;
28 return React.useRef(function RenderFunctionWrapper(restProps) {
29 return renderRef.current(restProps);
30 }).current;
31 }
32 function useWith(Wrapped, props) {
33 return useFC(function (restProps) {
34 return /*#__PURE__*/React.createElement(Wrapped, _extends({}, props, restProps));
35 });
36 }
37
38 exports.default = useWith;
39 exports.useFC = useFC;
40
41 Object.defineProperty(exports, '__esModule', { value: true });
42
43})));
44//# sourceMappingURL=use-with.umd.js.map