1 | "use strict";
|
2 |
|
3 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4 |
|
5 | var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
6 |
|
7 | Object.defineProperty(exports, "__esModule", {
|
8 | value: true
|
9 | });
|
10 | exports.default = void 0;
|
11 |
|
12 | var React = _interopRequireWildcard(require("react"));
|
13 |
|
14 | var _propTypes = _interopRequireDefault(require("prop-types"));
|
15 |
|
16 | var _utils = require("@material-ui/utils");
|
17 |
|
18 | var useEnhancedEffect = typeof window !== 'undefined' && process.env.NODE_ENV !== 'test' ? React.useLayoutEffect : React.useEffect;
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 | function NoSsr(props) {
|
30 | var children = props.children,
|
31 | _props$defer = props.defer,
|
32 | defer = _props$defer === void 0 ? false : _props$defer,
|
33 | _props$fallback = props.fallback,
|
34 | fallback = _props$fallback === void 0 ? null : _props$fallback;
|
35 |
|
36 | var _React$useState = React.useState(false),
|
37 | mountedState = _React$useState[0],
|
38 | setMountedState = _React$useState[1];
|
39 |
|
40 | useEnhancedEffect(function () {
|
41 | if (!defer) {
|
42 | setMountedState(true);
|
43 | }
|
44 | }, [defer]);
|
45 | React.useEffect(function () {
|
46 | if (defer) {
|
47 | setMountedState(true);
|
48 | }
|
49 | }, [defer]);
|
50 |
|
51 | return React.createElement(React.Fragment, null, mountedState ? children : fallback);
|
52 | }
|
53 |
|
54 | process.env.NODE_ENV !== "production" ? NoSsr.propTypes = {
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 | |
61 |
|
62 |
|
63 | children: _propTypes.default.node,
|
64 |
|
65 | |
66 |
|
67 |
|
68 |
|
69 | defer: _propTypes.default.bool,
|
70 |
|
71 | |
72 |
|
73 |
|
74 | fallback: _propTypes.default.node
|
75 | } : void 0;
|
76 |
|
77 | if (process.env.NODE_ENV !== 'production') {
|
78 |
|
79 | NoSsr['propTypes' + ''] = (0, _utils.exactProp)(NoSsr.propTypes);
|
80 | }
|
81 |
|
82 | var _default = NoSsr;
|
83 | exports.default = _default; |
\ | No newline at end of file |