1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, '__esModule', { value: true });
|
4 |
|
5 | var React = require('react');
|
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 React.createElement(Wrapped, _extends({}, props, restProps));
|
35 | });
|
36 | }
|
37 |
|
38 | exports.default = useWith;
|
39 | exports.useFC = useFC;
|
40 |
|