1 | import * as React from 'react';
|
2 |
|
3 | const NavigationContent = _ref => {
|
4 | let {
|
5 | render,
|
6 | children
|
7 | } = _ref;
|
8 | return render(children);
|
9 | };
|
10 |
|
11 | export default function useComponent(render) {
|
12 | const renderRef = React.useRef(render);
|
13 |
|
14 |
|
15 |
|
16 | renderRef.current = render;
|
17 | React.useEffect(() => {
|
18 | renderRef.current = null;
|
19 | });
|
20 | return React.useRef(_ref2 => {
|
21 | let {
|
22 | children
|
23 | } = _ref2;
|
24 | const render = renderRef.current;
|
25 |
|
26 | if (render === null) {
|
27 | throw new Error('The returned component must be rendered in the same render phase as the hook.');
|
28 | }
|
29 |
|
30 | return React.createElement(NavigationContent, {
|
31 | render: render
|
32 | }, children);
|
33 | }).current;
|
34 | }
|
35 |
|
\ | No newline at end of file |