1 | "use strict";
|
2 |
|
3 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4 | Object.defineProperty(exports, "__esModule", {
|
5 | value: true
|
6 | });
|
7 | exports.default = void 0;
|
8 | var React = _interopRequireWildcard(require("react"));
|
9 | var _propTypes = _interopRequireDefault(require("prop-types"));
|
10 | var _utils = require("@mui/utils");
|
11 | var _jsxRuntime = require("react/jsx-runtime");
|
12 | function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
13 | function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 | function NoSsr(props) {
|
33 | const {
|
34 | children,
|
35 | defer = false,
|
36 | fallback = null
|
37 | } = props;
|
38 | const [mountedState, setMountedState] = React.useState(false);
|
39 | (0, _utils.unstable_useEnhancedEffect)(() => {
|
40 | if (!defer) {
|
41 | setMountedState(true);
|
42 | }
|
43 | }, [defer]);
|
44 | React.useEffect(() => {
|
45 | if (defer) {
|
46 | setMountedState(true);
|
47 | }
|
48 | }, [defer]);
|
49 |
|
50 |
|
51 | return (0, _jsxRuntime.jsx)(React.Fragment, {
|
52 | children: mountedState ? children : fallback
|
53 | });
|
54 | }
|
55 | process.env.NODE_ENV !== "production" ? NoSsr.propTypes = {
|
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 | if (process.env.NODE_ENV !== 'production') {
|
77 |
|
78 | NoSsr['propTypes' + ''] = (0, _utils.exactProp)(NoSsr.propTypes);
|
79 | }
|
80 | var _default = NoSsr;
|
81 | exports.default = _default; |
\ | No newline at end of file |