react-test-renderer 16.12.0 → 16.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build-info.json +4 -4
- package/cjs/react-test-renderer-shallow.development.js +104 -141
- package/cjs/react-test-renderer-shallow.production.min.js +23 -22
- package/cjs/react-test-renderer.development.js +2241 -4549
- package/cjs/react-test-renderer.production.min.js +172 -175
- package/package.json +2 -2
- package/umd/react-test-renderer-shallow.development.js +884 -964
- package/umd/react-test-renderer-shallow.production.min.js +24 -24
- package/umd/react-test-renderer.development.js +12186 -14505
- package/umd/react-test-renderer.production.min.js +144 -145
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license React v16.
|
|
1
|
+
/** @license React v16.13.0
|
|
2
2
|
* react-test-renderer-shallow.development.js
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
@@ -10,1247 +10,1167 @@
|
|
|
10
10
|
'use strict';
|
|
11
11
|
|
|
12
12
|
(function (global, factory) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('react')) :
|
|
14
|
+
typeof define === 'function' && define.amd ? define(['react'], factory) :
|
|
15
|
+
(global = global || self, global.ReactShallowRenderer = factory(global.React));
|
|
16
16
|
}(this, (function (React) { 'use strict';
|
|
17
17
|
|
|
18
|
-
// Do not require this module directly! Use normal `invariant` calls with
|
|
19
|
-
// template literal strings. The messages will be replaced with error codes
|
|
20
|
-
// during build.
|
|
21
|
-
|
|
22
|
-
var
|
|
23
|
-
var _assign = ReactInternals.assign;
|
|
24
|
-
|
|
25
|
-
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
|
|
26
|
-
// nor polyfill, then a plain number is used for performance.
|
|
27
|
-
var hasSymbol = typeof Symbol === 'function' && Symbol.for;
|
|
28
|
-
var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
|
|
29
|
-
var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
|
|
30
|
-
var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
|
|
31
|
-
var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
|
|
32
|
-
var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
|
|
33
|
-
var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
|
|
34
|
-
var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
|
|
35
|
-
// (unstable) APIs that have been removed. Can we remove the symbols?
|
|
36
|
-
|
|
37
|
-
var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
|
|
38
|
-
var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
|
|
39
|
-
var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
|
|
40
|
-
var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
|
|
41
|
-
var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;
|
|
42
|
-
var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
|
|
43
|
-
var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Forked from fbjs/warning:
|
|
47
|
-
* https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
|
|
48
|
-
*
|
|
49
|
-
* Only change is we use console.warn instead of console.error,
|
|
50
|
-
* and do nothing when 'console' is not supported.
|
|
51
|
-
* This really simplifies the code.
|
|
52
|
-
* ---
|
|
53
|
-
* Similar to invariant but only logs a warning if the condition is not met.
|
|
54
|
-
* This can be used to log issues in development environments in critical
|
|
55
|
-
* paths. Removing the logging code for production environments will keep the
|
|
56
|
-
* same logic and follow the same code paths.
|
|
57
|
-
*/
|
|
58
|
-
{
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function typeOf(object) {
|
|
63
|
-
if (typeof object === 'object' && object !== null) {
|
|
64
|
-
var $$typeof = object.$$typeof;
|
|
65
|
-
|
|
66
|
-
switch ($$typeof) {
|
|
67
|
-
case REACT_ELEMENT_TYPE:
|
|
68
|
-
var type = object.type;
|
|
69
|
-
|
|
70
|
-
switch (type) {
|
|
71
|
-
case REACT_ASYNC_MODE_TYPE:
|
|
72
|
-
case REACT_CONCURRENT_MODE_TYPE:
|
|
73
|
-
case REACT_FRAGMENT_TYPE:
|
|
74
|
-
case REACT_PROFILER_TYPE:
|
|
75
|
-
case REACT_STRICT_MODE_TYPE:
|
|
76
|
-
case REACT_SUSPENSE_TYPE:
|
|
77
|
-
return type;
|
|
78
|
-
|
|
79
|
-
default:
|
|
80
|
-
var $$typeofType = type && type.$$typeof;
|
|
81
|
-
|
|
82
|
-
switch ($$typeofType) {
|
|
83
|
-
case REACT_CONTEXT_TYPE:
|
|
84
|
-
case REACT_FORWARD_REF_TYPE:
|
|
85
|
-
case REACT_LAZY_TYPE:
|
|
86
|
-
case REACT_MEMO_TYPE:
|
|
87
|
-
case REACT_PROVIDER_TYPE:
|
|
88
|
-
return $$typeofType;
|
|
89
|
-
|
|
90
|
-
default:
|
|
91
|
-
return $$typeof;
|
|
92
|
-
}
|
|
18
|
+
// Do not require this module directly! Use normal `invariant` calls with
|
|
19
|
+
// template literal strings. The messages will be replaced with error codes
|
|
20
|
+
// during build.
|
|
21
|
+
function formatProdErrorMessage(code) {
|
|
22
|
+
var url = 'https://reactjs.org/docs/error-decoder.html?invariant=' + code;
|
|
93
23
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
case REACT_PORTAL_TYPE:
|
|
97
|
-
return $$typeof;
|
|
24
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
25
|
+
url += '&args[]=' + encodeURIComponent(arguments[i]);
|
|
98
26
|
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
return undefined;
|
|
102
|
-
} // AsyncMode is deprecated along with isAsyncMode
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
27
|
|
|
28
|
+
return "Minified React error #" + code + "; visit " + url + " for the full message or " + 'use the non-minified dev environment for full errors and additional ' + 'helpful warnings.';
|
|
29
|
+
}
|
|
108
30
|
|
|
109
|
-
var
|
|
31
|
+
var ReactInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
32
|
+
var _assign = ReactInternals.assign;
|
|
110
33
|
|
|
34
|
+
var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; // Prevent newer renderers from RTE when used with older react package versions.
|
|
35
|
+
// Current owner and dispatcher used to share the same ref,
|
|
36
|
+
// but PR #14548 split them out to better support the react-debug-tools package.
|
|
111
37
|
|
|
38
|
+
if (!ReactSharedInternals.hasOwnProperty('ReactCurrentDispatcher')) {
|
|
39
|
+
ReactSharedInternals.ReactCurrentDispatcher = {
|
|
40
|
+
current: null
|
|
41
|
+
};
|
|
42
|
+
}
|
|
112
43
|
|
|
44
|
+
if (!ReactSharedInternals.hasOwnProperty('ReactCurrentBatchConfig')) {
|
|
45
|
+
ReactSharedInternals.ReactCurrentBatchConfig = {
|
|
46
|
+
suspense: null
|
|
47
|
+
};
|
|
48
|
+
}
|
|
113
49
|
|
|
50
|
+
function error(format) {
|
|
51
|
+
{
|
|
52
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
53
|
+
args[_key2 - 1] = arguments[_key2];
|
|
54
|
+
}
|
|
114
55
|
|
|
56
|
+
printWarning('error', format, args);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
115
59
|
|
|
60
|
+
function printWarning(level, format, args) {
|
|
61
|
+
// When changing this logic, you might want to also
|
|
62
|
+
// update consoleWithStackDev.www.js as well.
|
|
63
|
+
{
|
|
64
|
+
var hasExistingStack = args.length > 0 && typeof args[args.length - 1] === 'string' && args[args.length - 1].indexOf('\n in') === 0;
|
|
116
65
|
|
|
66
|
+
if (!hasExistingStack) {
|
|
67
|
+
var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
|
|
68
|
+
var stack = ReactDebugCurrentFrame.getStackAddendum();
|
|
117
69
|
|
|
70
|
+
if (stack !== '') {
|
|
71
|
+
format += '%s';
|
|
72
|
+
args = args.concat([stack]);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
118
75
|
|
|
76
|
+
var argsWithFormat = args.map(function (item) {
|
|
77
|
+
return '' + item;
|
|
78
|
+
}); // Careful: RN currently depends on this prefix
|
|
119
79
|
|
|
80
|
+
argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
|
|
81
|
+
// breaks IE9: https://github.com/facebook/react/issues/13610
|
|
82
|
+
// eslint-disable-next-line react-internal/no-production-logging
|
|
83
|
+
|
|
84
|
+
Function.prototype.apply.call(console[level], console, argsWithFormat);
|
|
85
|
+
|
|
86
|
+
try {
|
|
87
|
+
// --- Welcome to debugging React ---
|
|
88
|
+
// This error was thrown as a convenience so that you can use this stack
|
|
89
|
+
// to find the callsite that caused this warning to fire.
|
|
90
|
+
var argIndex = 0;
|
|
91
|
+
var message = 'Warning: ' + format.replace(/%s/g, function () {
|
|
92
|
+
return args[argIndex++];
|
|
93
|
+
});
|
|
94
|
+
throw new Error(message);
|
|
95
|
+
} catch (x) {}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
120
98
|
|
|
99
|
+
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
|
|
100
|
+
// nor polyfill, then a plain number is used for performance.
|
|
101
|
+
var hasSymbol = typeof Symbol === 'function' && Symbol.for;
|
|
102
|
+
var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
|
|
103
|
+
var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
|
|
104
|
+
var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
|
|
105
|
+
var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
|
|
106
|
+
var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
|
|
107
|
+
var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
|
|
108
|
+
var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
|
|
109
|
+
// (unstable) APIs that have been removed. Can we remove the symbols?
|
|
110
|
+
|
|
111
|
+
var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
|
|
112
|
+
var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
|
|
113
|
+
var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
|
|
114
|
+
var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
|
|
115
|
+
var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;
|
|
116
|
+
var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
|
|
117
|
+
var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
|
|
118
|
+
var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for('react.block') : 0xead9;
|
|
119
|
+
|
|
120
|
+
function typeOf(object) {
|
|
121
|
+
if (typeof object === 'object' && object !== null) {
|
|
122
|
+
var $$typeof = object.$$typeof;
|
|
123
|
+
|
|
124
|
+
switch ($$typeof) {
|
|
125
|
+
case REACT_ELEMENT_TYPE:
|
|
126
|
+
var type = object.type;
|
|
127
|
+
|
|
128
|
+
switch (type) {
|
|
129
|
+
case REACT_ASYNC_MODE_TYPE:
|
|
130
|
+
case REACT_CONCURRENT_MODE_TYPE:
|
|
131
|
+
case REACT_FRAGMENT_TYPE:
|
|
132
|
+
case REACT_PROFILER_TYPE:
|
|
133
|
+
case REACT_STRICT_MODE_TYPE:
|
|
134
|
+
case REACT_SUSPENSE_TYPE:
|
|
135
|
+
return type;
|
|
136
|
+
|
|
137
|
+
default:
|
|
138
|
+
var $$typeofType = type && type.$$typeof;
|
|
139
|
+
|
|
140
|
+
switch ($$typeofType) {
|
|
141
|
+
case REACT_CONTEXT_TYPE:
|
|
142
|
+
case REACT_FORWARD_REF_TYPE:
|
|
143
|
+
case REACT_LAZY_TYPE:
|
|
144
|
+
case REACT_MEMO_TYPE:
|
|
145
|
+
case REACT_PROVIDER_TYPE:
|
|
146
|
+
return $$typeofType;
|
|
147
|
+
|
|
148
|
+
default:
|
|
149
|
+
return $$typeof;
|
|
150
|
+
}
|
|
121
151
|
|
|
122
|
-
|
|
123
|
-
return typeOf(object) === REACT_FORWARD_REF_TYPE;
|
|
124
|
-
}
|
|
152
|
+
}
|
|
125
153
|
|
|
154
|
+
case REACT_PORTAL_TYPE:
|
|
155
|
+
return $$typeof;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
126
158
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
159
|
+
return undefined;
|
|
160
|
+
} // AsyncMode is deprecated along with isAsyncMode
|
|
161
|
+
var ForwardRef = REACT_FORWARD_REF_TYPE;
|
|
162
|
+
function isForwardRef(object) {
|
|
163
|
+
return typeOf(object) === REACT_FORWARD_REF_TYPE;
|
|
164
|
+
}
|
|
165
|
+
function isMemo(object) {
|
|
166
|
+
return typeOf(object) === REACT_MEMO_TYPE;
|
|
167
|
+
}
|
|
130
168
|
|
|
131
|
-
var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
|
|
132
|
-
|
|
133
|
-
|
|
169
|
+
var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
|
|
170
|
+
function describeComponentFrame (name, source, ownerName) {
|
|
171
|
+
var sourceInfo = '';
|
|
134
172
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
173
|
+
if (source) {
|
|
174
|
+
var path = source.fileName;
|
|
175
|
+
var fileName = path.replace(BEFORE_SLASH_RE, '');
|
|
138
176
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
177
|
+
{
|
|
178
|
+
// In DEV, include code for a common special case:
|
|
179
|
+
// prefer "folder/index.js" instead of just "index.js".
|
|
180
|
+
if (/^index\./.test(fileName)) {
|
|
181
|
+
var match = path.match(BEFORE_SLASH_RE);
|
|
144
182
|
|
|
145
|
-
|
|
146
|
-
|
|
183
|
+
if (match) {
|
|
184
|
+
var pathBeforeSlash = match[1];
|
|
147
185
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
186
|
+
if (pathBeforeSlash) {
|
|
187
|
+
var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, '');
|
|
188
|
+
fileName = folderName + '/' + fileName;
|
|
189
|
+
}
|
|
151
190
|
}
|
|
152
191
|
}
|
|
153
192
|
}
|
|
193
|
+
|
|
194
|
+
sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')';
|
|
195
|
+
} else if (ownerName) {
|
|
196
|
+
sourceInfo = ' (created by ' + ownerName + ')';
|
|
154
197
|
}
|
|
155
198
|
|
|
156
|
-
|
|
157
|
-
} else if (ownerName) {
|
|
158
|
-
sourceInfo = ' (created by ' + ownerName + ')';
|
|
199
|
+
return '\n in ' + (name || 'Unknown') + sourceInfo;
|
|
159
200
|
}
|
|
160
201
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
* Similar to invariant but only logs a warning if the condition is not met.
|
|
166
|
-
* This can be used to log issues in development environments in critical
|
|
167
|
-
* paths. Removing the logging code for production environments will keep the
|
|
168
|
-
* same logic and follow the same code paths.
|
|
169
|
-
*/
|
|
170
|
-
var warningWithoutStack = function () {};
|
|
202
|
+
var Resolved = 1;
|
|
203
|
+
function refineResolvedLazyComponent(lazyComponent) {
|
|
204
|
+
return lazyComponent._status === Resolved ? lazyComponent._result : null;
|
|
205
|
+
}
|
|
171
206
|
|
|
172
|
-
{
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
}
|
|
207
|
+
function getWrappedName(outerType, innerType, wrapperName) {
|
|
208
|
+
var functionName = innerType.displayName || innerType.name || '';
|
|
209
|
+
return outerType.displayName || (functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName);
|
|
210
|
+
}
|
|
177
211
|
|
|
178
|
-
|
|
179
|
-
|
|
212
|
+
function getComponentName(type) {
|
|
213
|
+
if (type == null) {
|
|
214
|
+
// Host root, text node or just invalid type.
|
|
215
|
+
return null;
|
|
180
216
|
}
|
|
181
217
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
218
|
+
{
|
|
219
|
+
if (typeof type.tag === 'number') {
|
|
220
|
+
error('Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.');
|
|
221
|
+
}
|
|
185
222
|
}
|
|
186
223
|
|
|
187
|
-
if (
|
|
188
|
-
return;
|
|
224
|
+
if (typeof type === 'function') {
|
|
225
|
+
return type.displayName || type.name || null;
|
|
189
226
|
}
|
|
190
227
|
|
|
191
|
-
if (typeof
|
|
192
|
-
|
|
193
|
-
return '' + item;
|
|
194
|
-
});
|
|
195
|
-
argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
|
|
196
|
-
// breaks IE9: https://github.com/facebook/react/issues/13610
|
|
197
|
-
|
|
198
|
-
Function.prototype.apply.call(console.error, console, argsWithFormat);
|
|
228
|
+
if (typeof type === 'string') {
|
|
229
|
+
return type;
|
|
199
230
|
}
|
|
200
231
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
// to find the callsite that caused this warning to fire.
|
|
205
|
-
var argIndex = 0;
|
|
206
|
-
var message = 'Warning: ' + format.replace(/%s/g, function () {
|
|
207
|
-
return args[argIndex++];
|
|
208
|
-
});
|
|
209
|
-
throw new Error(message);
|
|
210
|
-
} catch (x) {}
|
|
211
|
-
};
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
var warningWithoutStack$1 = warningWithoutStack;
|
|
232
|
+
switch (type) {
|
|
233
|
+
case REACT_FRAGMENT_TYPE:
|
|
234
|
+
return 'Fragment';
|
|
215
235
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
// but PR #14548 split them out to better support the react-debug-tools package.
|
|
219
|
-
|
|
220
|
-
if (!ReactSharedInternals.hasOwnProperty('ReactCurrentDispatcher')) {
|
|
221
|
-
ReactSharedInternals.ReactCurrentDispatcher = {
|
|
222
|
-
current: null
|
|
223
|
-
};
|
|
224
|
-
}
|
|
236
|
+
case REACT_PORTAL_TYPE:
|
|
237
|
+
return 'Portal';
|
|
225
238
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
suspense: null
|
|
229
|
-
};
|
|
230
|
-
}
|
|
239
|
+
case REACT_PROFILER_TYPE:
|
|
240
|
+
return "Profiler";
|
|
231
241
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
* This can be used to log issues in development environments in critical
|
|
235
|
-
* paths. Removing the logging code for production environments will keep the
|
|
236
|
-
* same logic and follow the same code paths.
|
|
237
|
-
*/
|
|
242
|
+
case REACT_STRICT_MODE_TYPE:
|
|
243
|
+
return 'StrictMode';
|
|
238
244
|
|
|
239
|
-
|
|
245
|
+
case REACT_SUSPENSE_TYPE:
|
|
246
|
+
return 'Suspense';
|
|
240
247
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
if (condition) {
|
|
244
|
-
return;
|
|
248
|
+
case REACT_SUSPENSE_LIST_TYPE:
|
|
249
|
+
return 'SuspenseList';
|
|
245
250
|
}
|
|
246
251
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
args[_key - 2] = arguments[_key];
|
|
252
|
-
}
|
|
252
|
+
if (typeof type === 'object') {
|
|
253
|
+
switch (type.$$typeof) {
|
|
254
|
+
case REACT_CONTEXT_TYPE:
|
|
255
|
+
return 'Context.Consumer';
|
|
253
256
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
}
|
|
257
|
+
case REACT_PROVIDER_TYPE:
|
|
258
|
+
return 'Context.Provider';
|
|
257
259
|
|
|
258
|
-
|
|
260
|
+
case REACT_FORWARD_REF_TYPE:
|
|
261
|
+
return getWrappedName(type, type.render, 'ForwardRef');
|
|
259
262
|
|
|
260
|
-
|
|
263
|
+
case REACT_MEMO_TYPE:
|
|
264
|
+
return getComponentName(type.type);
|
|
261
265
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
}
|
|
266
|
+
case REACT_BLOCK_TYPE:
|
|
267
|
+
return getComponentName(type.render);
|
|
265
268
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
269
|
+
case REACT_LAZY_TYPE:
|
|
270
|
+
{
|
|
271
|
+
var thenable = type;
|
|
272
|
+
var resolvedThenable = refineResolvedLazyComponent(thenable);
|
|
270
273
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
return null;
|
|
275
|
-
}
|
|
274
|
+
if (resolvedThenable) {
|
|
275
|
+
return getComponentName(resolvedThenable);
|
|
276
|
+
}
|
|
276
277
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
278
|
+
break;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
280
281
|
}
|
|
281
|
-
}
|
|
282
282
|
|
|
283
|
-
|
|
284
|
-
return type.displayName || type.name || null;
|
|
283
|
+
return null;
|
|
285
284
|
}
|
|
286
285
|
|
|
287
|
-
|
|
288
|
-
|
|
286
|
+
/**
|
|
287
|
+
* inlined Object.is polyfill to avoid requiring consumers ship their own
|
|
288
|
+
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
|
|
289
|
+
*/
|
|
290
|
+
function is(x, y) {
|
|
291
|
+
return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare
|
|
292
|
+
;
|
|
289
293
|
}
|
|
290
294
|
|
|
291
|
-
|
|
292
|
-
case REACT_FRAGMENT_TYPE:
|
|
293
|
-
return 'Fragment';
|
|
294
|
-
|
|
295
|
-
case REACT_PORTAL_TYPE:
|
|
296
|
-
return 'Portal';
|
|
297
|
-
|
|
298
|
-
case REACT_PROFILER_TYPE:
|
|
299
|
-
return "Profiler";
|
|
295
|
+
var objectIs = typeof Object.is === 'function' ? Object.is : is;
|
|
300
296
|
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
case REACT_SUSPENSE_LIST_TYPE:
|
|
308
|
-
return 'SuspenseList';
|
|
309
|
-
}
|
|
297
|
+
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
298
|
+
/**
|
|
299
|
+
* Performs equality by iterating through keys on an object and returning false
|
|
300
|
+
* when any key has values which are not strictly equal between the arguments.
|
|
301
|
+
* Returns true when the values of all keys are strictly equal.
|
|
302
|
+
*/
|
|
310
303
|
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
304
|
+
function shallowEqual(objA, objB) {
|
|
305
|
+
if (objectIs(objA, objB)) {
|
|
306
|
+
return true;
|
|
307
|
+
}
|
|
315
308
|
|
|
316
|
-
|
|
317
|
-
|
|
309
|
+
if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
|
|
310
|
+
return false;
|
|
311
|
+
}
|
|
318
312
|
|
|
319
|
-
|
|
320
|
-
|
|
313
|
+
var keysA = Object.keys(objA);
|
|
314
|
+
var keysB = Object.keys(objB);
|
|
321
315
|
|
|
322
|
-
|
|
323
|
-
|
|
316
|
+
if (keysA.length !== keysB.length) {
|
|
317
|
+
return false;
|
|
318
|
+
} // Test for A's keys different from B.
|
|
324
319
|
|
|
325
|
-
case REACT_LAZY_TYPE:
|
|
326
|
-
{
|
|
327
|
-
var thenable = type;
|
|
328
|
-
var resolvedThenable = refineResolvedLazyComponent(thenable);
|
|
329
320
|
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
break;
|
|
335
|
-
}
|
|
321
|
+
for (var i = 0; i < keysA.length; i++) {
|
|
322
|
+
if (!hasOwnProperty.call(objB, keysA[i]) || !objectIs(objA[keysA[i]], objB[keysA[i]])) {
|
|
323
|
+
return false;
|
|
324
|
+
}
|
|
336
325
|
}
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
return null;
|
|
340
|
-
}
|
|
341
326
|
|
|
342
|
-
/**
|
|
343
|
-
* inlined Object.is polyfill to avoid requiring consumers ship their own
|
|
344
|
-
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
|
|
345
|
-
*/
|
|
346
|
-
function is(x, y) {
|
|
347
|
-
return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare
|
|
348
|
-
;
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
var is$1 = typeof Object.is === 'function' ? Object.is : is;
|
|
352
|
-
|
|
353
|
-
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
354
|
-
/**
|
|
355
|
-
* Performs equality by iterating through keys on an object and returning false
|
|
356
|
-
* when any key has values which are not strictly equal between the arguments.
|
|
357
|
-
* Returns true when the values of all keys are strictly equal.
|
|
358
|
-
*/
|
|
359
|
-
|
|
360
|
-
function shallowEqual(objA, objB) {
|
|
361
|
-
if (is$1(objA, objB)) {
|
|
362
327
|
return true;
|
|
363
328
|
}
|
|
364
329
|
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
330
|
+
/**
|
|
331
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
332
|
+
*
|
|
333
|
+
* This source code is licensed under the MIT license found in the
|
|
334
|
+
* LICENSE file in the root directory of this source tree.
|
|
335
|
+
*/
|
|
368
336
|
|
|
369
|
-
var
|
|
370
|
-
var keysB = Object.keys(objB);
|
|
337
|
+
var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
|
|
371
338
|
|
|
372
|
-
|
|
373
|
-
return false;
|
|
374
|
-
} // Test for A's keys different from B.
|
|
339
|
+
var ReactPropTypesSecret_1 = ReactPropTypesSecret;
|
|
375
340
|
|
|
341
|
+
var printWarning$1 = function() {};
|
|
376
342
|
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
343
|
+
{
|
|
344
|
+
var ReactPropTypesSecret$1 = ReactPropTypesSecret_1;
|
|
345
|
+
var loggedTypeFailures = {};
|
|
346
|
+
var has = Function.call.bind(Object.prototype.hasOwnProperty);
|
|
347
|
+
|
|
348
|
+
printWarning$1 = function(text) {
|
|
349
|
+
var message = 'Warning: ' + text;
|
|
350
|
+
if (typeof console !== 'undefined') {
|
|
351
|
+
console.error(message);
|
|
352
|
+
}
|
|
353
|
+
try {
|
|
354
|
+
// --- Welcome to debugging React ---
|
|
355
|
+
// This error was thrown as a convenience so that you can use this stack
|
|
356
|
+
// to find the callsite that caused this warning to fire.
|
|
357
|
+
throw new Error(message);
|
|
358
|
+
} catch (x) {}
|
|
359
|
+
};
|
|
381
360
|
}
|
|
382
361
|
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
var
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
printWarning$1 = function(text) {
|
|
427
|
-
var message = 'Warning: ' + text;
|
|
428
|
-
if (typeof console !== 'undefined') {
|
|
429
|
-
console.error(message);
|
|
430
|
-
}
|
|
431
|
-
try {
|
|
432
|
-
// --- Welcome to debugging React ---
|
|
433
|
-
// This error was thrown as a convenience so that you can use this stack
|
|
434
|
-
// to find the callsite that caused this warning to fire.
|
|
435
|
-
throw new Error(message);
|
|
436
|
-
} catch (x) {}
|
|
437
|
-
};
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
/**
|
|
441
|
-
* Assert that the values match with the type specs.
|
|
442
|
-
* Error messages are memorized and will only be shown once.
|
|
443
|
-
*
|
|
444
|
-
* @param {object} typeSpecs Map of name to a ReactPropType
|
|
445
|
-
* @param {object} values Runtime values that need to be type-checked
|
|
446
|
-
* @param {string} location e.g. "prop", "context", "child context"
|
|
447
|
-
* @param {string} componentName Name of the component for error messages.
|
|
448
|
-
* @param {?Function} getStack Returns the component stack.
|
|
449
|
-
* @private
|
|
450
|
-
*/
|
|
451
|
-
function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
|
|
452
|
-
{
|
|
453
|
-
for (var typeSpecName in typeSpecs) {
|
|
454
|
-
if (has(typeSpecs, typeSpecName)) {
|
|
455
|
-
var error;
|
|
456
|
-
// Prop type validation may throw. In case they do, we don't want to
|
|
457
|
-
// fail the render phase where it didn't fail before. So we log it.
|
|
458
|
-
// After these have been cleaned up, we'll let them throw.
|
|
459
|
-
try {
|
|
460
|
-
// This is intentionally an invariant that gets caught. It's the same
|
|
461
|
-
// behavior as without this statement except with a better message.
|
|
462
|
-
if (typeof typeSpecs[typeSpecName] !== 'function') {
|
|
463
|
-
var err = Error(
|
|
464
|
-
(componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' +
|
|
465
|
-
'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.'
|
|
362
|
+
/**
|
|
363
|
+
* Assert that the values match with the type specs.
|
|
364
|
+
* Error messages are memorized and will only be shown once.
|
|
365
|
+
*
|
|
366
|
+
* @param {object} typeSpecs Map of name to a ReactPropType
|
|
367
|
+
* @param {object} values Runtime values that need to be type-checked
|
|
368
|
+
* @param {string} location e.g. "prop", "context", "child context"
|
|
369
|
+
* @param {string} componentName Name of the component for error messages.
|
|
370
|
+
* @param {?Function} getStack Returns the component stack.
|
|
371
|
+
* @private
|
|
372
|
+
*/
|
|
373
|
+
function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
|
|
374
|
+
{
|
|
375
|
+
for (var typeSpecName in typeSpecs) {
|
|
376
|
+
if (has(typeSpecs, typeSpecName)) {
|
|
377
|
+
var error;
|
|
378
|
+
// Prop type validation may throw. In case they do, we don't want to
|
|
379
|
+
// fail the render phase where it didn't fail before. So we log it.
|
|
380
|
+
// After these have been cleaned up, we'll let them throw.
|
|
381
|
+
try {
|
|
382
|
+
// This is intentionally an invariant that gets caught. It's the same
|
|
383
|
+
// behavior as without this statement except with a better message.
|
|
384
|
+
if (typeof typeSpecs[typeSpecName] !== 'function') {
|
|
385
|
+
var err = Error(
|
|
386
|
+
(componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' +
|
|
387
|
+
'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.'
|
|
388
|
+
);
|
|
389
|
+
err.name = 'Invariant Violation';
|
|
390
|
+
throw err;
|
|
391
|
+
}
|
|
392
|
+
error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret$1);
|
|
393
|
+
} catch (ex) {
|
|
394
|
+
error = ex;
|
|
395
|
+
}
|
|
396
|
+
if (error && !(error instanceof Error)) {
|
|
397
|
+
printWarning$1(
|
|
398
|
+
(componentName || 'React class') + ': type specification of ' +
|
|
399
|
+
location + ' `' + typeSpecName + '` is invalid; the type checker ' +
|
|
400
|
+
'function must return `null` or an `Error` but returned a ' + typeof error + '. ' +
|
|
401
|
+
'You may have forgotten to pass an argument to the type checker ' +
|
|
402
|
+
'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +
|
|
403
|
+
'shape all require an argument).'
|
|
466
404
|
);
|
|
467
|
-
err.name = 'Invariant Violation';
|
|
468
|
-
throw err;
|
|
469
405
|
}
|
|
470
|
-
error
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
if (error && !(error instanceof Error)) {
|
|
475
|
-
printWarning$1(
|
|
476
|
-
(componentName || 'React class') + ': type specification of ' +
|
|
477
|
-
location + ' `' + typeSpecName + '` is invalid; the type checker ' +
|
|
478
|
-
'function must return `null` or an `Error` but returned a ' + typeof error + '. ' +
|
|
479
|
-
'You may have forgotten to pass an argument to the type checker ' +
|
|
480
|
-
'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +
|
|
481
|
-
'shape all require an argument).'
|
|
482
|
-
);
|
|
483
|
-
}
|
|
484
|
-
if (error instanceof Error && !(error.message in loggedTypeFailures)) {
|
|
485
|
-
// Only monitor this failure once because there tends to be a lot of the
|
|
486
|
-
// same error.
|
|
487
|
-
loggedTypeFailures[error.message] = true;
|
|
406
|
+
if (error instanceof Error && !(error.message in loggedTypeFailures)) {
|
|
407
|
+
// Only monitor this failure once because there tends to be a lot of the
|
|
408
|
+
// same error.
|
|
409
|
+
loggedTypeFailures[error.message] = true;
|
|
488
410
|
|
|
489
|
-
|
|
411
|
+
var stack = getStack ? getStack() : '';
|
|
490
412
|
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
413
|
+
printWarning$1(
|
|
414
|
+
'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '')
|
|
415
|
+
);
|
|
416
|
+
}
|
|
494
417
|
}
|
|
495
418
|
}
|
|
496
419
|
}
|
|
497
420
|
}
|
|
498
|
-
}
|
|
499
421
|
|
|
500
|
-
/**
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
checkPropTypes.resetWarningCache = function() {
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
};
|
|
422
|
+
/**
|
|
423
|
+
* Resets warning cache when testing.
|
|
424
|
+
*
|
|
425
|
+
* @private
|
|
426
|
+
*/
|
|
427
|
+
checkPropTypes.resetWarningCache = function() {
|
|
428
|
+
{
|
|
429
|
+
loggedTypeFailures = {};
|
|
430
|
+
}
|
|
431
|
+
};
|
|
510
432
|
|
|
511
|
-
var checkPropTypes_1 = checkPropTypes;
|
|
433
|
+
var checkPropTypes_1 = checkPropTypes;
|
|
512
434
|
|
|
513
|
-
var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
|
|
514
|
-
var RE_RENDER_LIMIT = 25;
|
|
515
|
-
var emptyObject = {};
|
|
435
|
+
var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
|
|
436
|
+
var RE_RENDER_LIMIT = 25;
|
|
437
|
+
var emptyObject = {};
|
|
516
438
|
|
|
517
|
-
{
|
|
518
|
-
|
|
519
|
-
} // In DEV, this is the name of the currently executing primitive hook
|
|
439
|
+
{
|
|
440
|
+
Object.freeze(emptyObject);
|
|
441
|
+
} // In DEV, this is the name of the currently executing primitive hook
|
|
520
442
|
|
|
521
443
|
|
|
522
|
-
var currentHookNameInDev;
|
|
444
|
+
var currentHookNameInDev;
|
|
523
445
|
|
|
524
|
-
function areHookInputsEqual(nextDeps, prevDeps) {
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
// passed inline.
|
|
446
|
+
function areHookInputsEqual(nextDeps, prevDeps) {
|
|
447
|
+
if (prevDeps === null) {
|
|
448
|
+
{
|
|
449
|
+
error('%s received a final argument during this render, but not during ' + 'the previous render. Even though the final argument is optional, ' + 'its type cannot change between renders.', currentHookNameInDev);
|
|
450
|
+
}
|
|
530
451
|
|
|
452
|
+
return false;
|
|
453
|
+
}
|
|
531
454
|
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
455
|
+
{
|
|
456
|
+
// Don't bother comparing lengths in prod because these arrays should be
|
|
457
|
+
// passed inline.
|
|
458
|
+
if (nextDeps.length !== prevDeps.length) {
|
|
459
|
+
error('The final argument passed to %s changed size between renders. The ' + 'order and size of this array must remain constant.\n\n' + 'Previous: %s\n' + 'Incoming: %s', currentHookNameInDev, "[" + nextDeps.join(', ') + "]", "[" + prevDeps.join(', ') + "]");
|
|
460
|
+
}
|
|
461
|
+
}
|
|
535
462
|
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
463
|
+
for (var i = 0; i < prevDeps.length && i < nextDeps.length; i++) {
|
|
464
|
+
if (objectIs(nextDeps[i], prevDeps[i])) {
|
|
465
|
+
continue;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
return false;
|
|
539
469
|
}
|
|
540
470
|
|
|
541
|
-
return
|
|
471
|
+
return true;
|
|
542
472
|
}
|
|
543
473
|
|
|
544
|
-
|
|
545
|
-
|
|
474
|
+
var Updater =
|
|
475
|
+
/*#__PURE__*/
|
|
476
|
+
function () {
|
|
477
|
+
function Updater(renderer) {
|
|
478
|
+
this._renderer = renderer;
|
|
479
|
+
this._callbacks = [];
|
|
480
|
+
}
|
|
546
481
|
|
|
547
|
-
var
|
|
548
|
-
/*#__PURE__*/
|
|
549
|
-
function () {
|
|
550
|
-
function Updater(renderer) {
|
|
551
|
-
this._renderer = renderer;
|
|
552
|
-
this._callbacks = [];
|
|
553
|
-
}
|
|
482
|
+
var _proto = Updater.prototype;
|
|
554
483
|
|
|
555
|
-
|
|
484
|
+
_proto._enqueueCallback = function _enqueueCallback(callback, publicInstance) {
|
|
485
|
+
if (typeof callback === 'function' && publicInstance) {
|
|
486
|
+
this._callbacks.push({
|
|
487
|
+
callback: callback,
|
|
488
|
+
publicInstance: publicInstance
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
};
|
|
556
492
|
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
this._callbacks
|
|
560
|
-
|
|
561
|
-
|
|
493
|
+
_proto._invokeCallbacks = function _invokeCallbacks() {
|
|
494
|
+
var callbacks = this._callbacks;
|
|
495
|
+
this._callbacks = [];
|
|
496
|
+
callbacks.forEach(function (_ref) {
|
|
497
|
+
var callback = _ref.callback,
|
|
498
|
+
publicInstance = _ref.publicInstance;
|
|
499
|
+
callback.call(publicInstance);
|
|
562
500
|
});
|
|
563
|
-
}
|
|
564
|
-
};
|
|
501
|
+
};
|
|
565
502
|
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
callbacks.forEach(function (_ref) {
|
|
570
|
-
var callback = _ref.callback,
|
|
571
|
-
publicInstance = _ref.publicInstance;
|
|
572
|
-
callback.call(publicInstance);
|
|
573
|
-
});
|
|
574
|
-
};
|
|
503
|
+
_proto.isMounted = function isMounted(publicInstance) {
|
|
504
|
+
return !!this._renderer._element;
|
|
505
|
+
};
|
|
575
506
|
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
};
|
|
507
|
+
_proto.enqueueForceUpdate = function enqueueForceUpdate(publicInstance, callback, callerName) {
|
|
508
|
+
this._enqueueCallback(callback, publicInstance);
|
|
579
509
|
|
|
580
|
-
|
|
581
|
-
this._enqueueCallback(callback, publicInstance);
|
|
510
|
+
this._renderer._forcedUpdate = true;
|
|
582
511
|
|
|
583
|
-
|
|
512
|
+
this._renderer.render(this._renderer._element, this._renderer._context);
|
|
513
|
+
};
|
|
584
514
|
|
|
585
|
-
|
|
586
|
-
|
|
515
|
+
_proto.enqueueReplaceState = function enqueueReplaceState(publicInstance, completeState, callback, callerName) {
|
|
516
|
+
this._enqueueCallback(callback, publicInstance);
|
|
587
517
|
|
|
588
|
-
|
|
589
|
-
this._enqueueCallback(callback, publicInstance);
|
|
518
|
+
this._renderer._newState = completeState;
|
|
590
519
|
|
|
591
|
-
|
|
520
|
+
this._renderer.render(this._renderer._element, this._renderer._context);
|
|
521
|
+
};
|
|
592
522
|
|
|
593
|
-
|
|
594
|
-
|
|
523
|
+
_proto.enqueueSetState = function enqueueSetState(publicInstance, partialState, callback, callerName) {
|
|
524
|
+
this._enqueueCallback(callback, publicInstance);
|
|
595
525
|
|
|
596
|
-
|
|
597
|
-
this._enqueueCallback(callback, publicInstance);
|
|
526
|
+
var currentState = this._renderer._newState || publicInstance.state;
|
|
598
527
|
|
|
599
|
-
|
|
528
|
+
if (typeof partialState === 'function') {
|
|
529
|
+
partialState = partialState.call(publicInstance, currentState, publicInstance.props);
|
|
530
|
+
} // Null and undefined are treated as no-ops.
|
|
600
531
|
|
|
601
|
-
if (typeof partialState === 'function') {
|
|
602
|
-
partialState = partialState.call(publicInstance, currentState, publicInstance.props);
|
|
603
|
-
} // Null and undefined are treated as no-ops.
|
|
604
532
|
|
|
533
|
+
if (partialState === null || partialState === undefined) {
|
|
534
|
+
return;
|
|
535
|
+
}
|
|
605
536
|
|
|
606
|
-
|
|
607
|
-
return;
|
|
608
|
-
}
|
|
537
|
+
this._renderer._newState = _assign({}, currentState, {}, partialState);
|
|
609
538
|
|
|
610
|
-
|
|
539
|
+
this._renderer.render(this._renderer._element, this._renderer._context);
|
|
540
|
+
};
|
|
611
541
|
|
|
612
|
-
|
|
613
|
-
};
|
|
542
|
+
return Updater;
|
|
543
|
+
}();
|
|
614
544
|
|
|
615
|
-
|
|
616
|
-
|
|
545
|
+
function createHook() {
|
|
546
|
+
return {
|
|
547
|
+
memoizedState: null,
|
|
548
|
+
queue: null,
|
|
549
|
+
next: null
|
|
550
|
+
};
|
|
551
|
+
}
|
|
617
552
|
|
|
618
|
-
function
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
next: null
|
|
623
|
-
};
|
|
624
|
-
}
|
|
553
|
+
function basicStateReducer(state, action) {
|
|
554
|
+
// $FlowFixMe: Flow doesn't like mixed types
|
|
555
|
+
return typeof action === 'function' ? action(state) : action;
|
|
556
|
+
}
|
|
625
557
|
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
558
|
+
var ReactShallowRenderer =
|
|
559
|
+
/*#__PURE__*/
|
|
560
|
+
function () {
|
|
561
|
+
function ReactShallowRenderer() {
|
|
562
|
+
this._reset();
|
|
563
|
+
}
|
|
629
564
|
|
|
630
|
-
var
|
|
631
|
-
/*#__PURE__*/
|
|
632
|
-
function () {
|
|
633
|
-
function ReactShallowRenderer() {
|
|
634
|
-
this._reset();
|
|
635
|
-
}
|
|
565
|
+
var _proto2 = ReactShallowRenderer.prototype;
|
|
636
566
|
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
this._numberOfReRenders = 0;
|
|
655
|
-
};
|
|
567
|
+
_proto2._reset = function _reset() {
|
|
568
|
+
this._context = null;
|
|
569
|
+
this._element = null;
|
|
570
|
+
this._instance = null;
|
|
571
|
+
this._newState = null;
|
|
572
|
+
this._rendered = null;
|
|
573
|
+
this._rendering = false;
|
|
574
|
+
this._forcedUpdate = false;
|
|
575
|
+
this._updater = new Updater(this);
|
|
576
|
+
this._dispatcher = this._createDispatcher();
|
|
577
|
+
this._workInProgressHook = null;
|
|
578
|
+
this._firstWorkInProgressHook = null;
|
|
579
|
+
this._isReRender = false;
|
|
580
|
+
this._didScheduleRenderPhaseUpdate = false;
|
|
581
|
+
this._renderPhaseUpdates = null;
|
|
582
|
+
this._numberOfReRenders = 0;
|
|
583
|
+
};
|
|
656
584
|
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
585
|
+
_proto2._validateCurrentlyRenderingComponent = function _validateCurrentlyRenderingComponent() {
|
|
586
|
+
if (!(this._rendering && !this._instance)) {
|
|
587
|
+
{
|
|
588
|
+
throw Error( "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem." );
|
|
589
|
+
}
|
|
661
590
|
}
|
|
662
|
-
}
|
|
663
|
-
};
|
|
591
|
+
};
|
|
664
592
|
|
|
665
|
-
|
|
666
|
-
|
|
593
|
+
_proto2._createDispatcher = function _createDispatcher() {
|
|
594
|
+
var _this = this;
|
|
667
595
|
|
|
668
|
-
|
|
669
|
-
|
|
596
|
+
var useReducer = function (reducer, initialArg, init) {
|
|
597
|
+
_this._validateCurrentlyRenderingComponent();
|
|
670
598
|
|
|
671
|
-
|
|
599
|
+
_this._createWorkInProgressHook();
|
|
672
600
|
|
|
673
|
-
|
|
601
|
+
var workInProgressHook = _this._workInProgressHook;
|
|
674
602
|
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
603
|
+
if (_this._isReRender) {
|
|
604
|
+
// This is a re-render.
|
|
605
|
+
var queue = workInProgressHook.queue;
|
|
606
|
+
var dispatch = queue.dispatch;
|
|
679
607
|
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
608
|
+
if (_this._numberOfReRenders > 0) {
|
|
609
|
+
// Apply the new render phase updates to the previous current hook.
|
|
610
|
+
if (_this._renderPhaseUpdates !== null) {
|
|
611
|
+
// Render phase updates are stored in a map of queue -> linked list
|
|
612
|
+
var firstRenderPhaseUpdate = _this._renderPhaseUpdates.get(queue);
|
|
685
613
|
|
|
686
|
-
|
|
687
|
-
|
|
614
|
+
if (firstRenderPhaseUpdate !== undefined) {
|
|
615
|
+
_this._renderPhaseUpdates.delete(queue);
|
|
688
616
|
|
|
689
|
-
|
|
690
|
-
|
|
617
|
+
var _newState = workInProgressHook.memoizedState;
|
|
618
|
+
var _update = firstRenderPhaseUpdate;
|
|
691
619
|
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
620
|
+
do {
|
|
621
|
+
var action = _update.action;
|
|
622
|
+
_newState = reducer(_newState, action);
|
|
623
|
+
_update = _update.next;
|
|
624
|
+
} while (_update !== null);
|
|
697
625
|
|
|
698
|
-
|
|
699
|
-
|
|
626
|
+
workInProgressHook.memoizedState = _newState;
|
|
627
|
+
return [_newState, dispatch];
|
|
628
|
+
}
|
|
700
629
|
}
|
|
701
|
-
}
|
|
702
630
|
|
|
703
|
-
|
|
704
|
-
|
|
631
|
+
return [workInProgressHook.memoizedState, dispatch];
|
|
632
|
+
} // Process updates outside of render
|
|
705
633
|
|
|
706
634
|
|
|
707
|
-
|
|
708
|
-
|
|
635
|
+
var newState = workInProgressHook.memoizedState;
|
|
636
|
+
var update = queue.first;
|
|
709
637
|
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
638
|
+
if (update !== null) {
|
|
639
|
+
do {
|
|
640
|
+
var _action = update.action;
|
|
641
|
+
newState = reducer(newState, _action);
|
|
642
|
+
update = update.next;
|
|
643
|
+
} while (update !== null);
|
|
716
644
|
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
return [newState, dispatch];
|
|
722
|
-
} else {
|
|
723
|
-
var initialState;
|
|
645
|
+
queue.first = null;
|
|
646
|
+
workInProgressHook.memoizedState = newState;
|
|
647
|
+
}
|
|
724
648
|
|
|
725
|
-
|
|
726
|
-
// Special case for `useState`.
|
|
727
|
-
initialState = typeof initialArg === 'function' ? initialArg() : initialArg;
|
|
649
|
+
return [newState, dispatch];
|
|
728
650
|
} else {
|
|
729
|
-
initialState
|
|
730
|
-
}
|
|
651
|
+
var initialState;
|
|
731
652
|
|
|
732
|
-
|
|
653
|
+
if (reducer === basicStateReducer) {
|
|
654
|
+
// Special case for `useState`.
|
|
655
|
+
initialState = typeof initialArg === 'function' ? initialArg() : initialArg;
|
|
656
|
+
} else {
|
|
657
|
+
initialState = init !== undefined ? init(initialArg) : initialArg;
|
|
658
|
+
}
|
|
733
659
|
|
|
734
|
-
|
|
735
|
-
first: null,
|
|
736
|
-
dispatch: null
|
|
737
|
-
};
|
|
660
|
+
workInProgressHook.memoizedState = initialState;
|
|
738
661
|
|
|
739
|
-
|
|
662
|
+
var _queue = workInProgressHook.queue = {
|
|
663
|
+
first: null,
|
|
664
|
+
dispatch: null
|
|
665
|
+
};
|
|
740
666
|
|
|
741
|
-
|
|
742
|
-
}
|
|
743
|
-
};
|
|
667
|
+
var _dispatch = _queue.dispatch = _this._dispatchAction.bind(_this, _queue);
|
|
744
668
|
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
};
|
|
669
|
+
return [workInProgressHook.memoizedState, _dispatch];
|
|
670
|
+
}
|
|
671
|
+
};
|
|
749
672
|
|
|
750
|
-
|
|
751
|
-
|
|
673
|
+
var useState = function (initialState) {
|
|
674
|
+
return useReducer(basicStateReducer, // useReducer has a special case to support lazy useState initializers
|
|
675
|
+
initialState);
|
|
676
|
+
};
|
|
677
|
+
|
|
678
|
+
var useMemo = function (nextCreate, deps) {
|
|
679
|
+
_this._validateCurrentlyRenderingComponent();
|
|
752
680
|
|
|
753
|
-
|
|
681
|
+
_this._createWorkInProgressHook();
|
|
754
682
|
|
|
755
|
-
|
|
683
|
+
var nextDeps = deps !== undefined ? deps : null;
|
|
756
684
|
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
685
|
+
if (_this._workInProgressHook !== null && _this._workInProgressHook.memoizedState !== null) {
|
|
686
|
+
var prevState = _this._workInProgressHook.memoizedState;
|
|
687
|
+
var prevDeps = prevState[1];
|
|
760
688
|
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
689
|
+
if (nextDeps !== null) {
|
|
690
|
+
if (areHookInputsEqual(nextDeps, prevDeps)) {
|
|
691
|
+
return prevState[0];
|
|
692
|
+
}
|
|
764
693
|
}
|
|
765
694
|
}
|
|
766
|
-
}
|
|
767
|
-
|
|
768
|
-
var nextValue = nextCreate();
|
|
769
|
-
_this._workInProgressHook.memoizedState = [nextValue, nextDeps];
|
|
770
|
-
return nextValue;
|
|
771
|
-
};
|
|
772
695
|
|
|
773
|
-
|
|
774
|
-
|
|
696
|
+
var nextValue = nextCreate();
|
|
697
|
+
_this._workInProgressHook.memoizedState = [nextValue, nextDeps];
|
|
698
|
+
return nextValue;
|
|
699
|
+
};
|
|
775
700
|
|
|
776
|
-
|
|
701
|
+
var useRef = function (initialValue) {
|
|
702
|
+
_this._validateCurrentlyRenderingComponent();
|
|
777
703
|
|
|
778
|
-
|
|
704
|
+
_this._createWorkInProgressHook();
|
|
779
705
|
|
|
780
|
-
|
|
781
|
-
var ref = {
|
|
782
|
-
current: initialValue
|
|
783
|
-
};
|
|
706
|
+
var previousRef = _this._workInProgressHook.memoizedState;
|
|
784
707
|
|
|
785
|
-
{
|
|
786
|
-
|
|
787
|
-
|
|
708
|
+
if (previousRef === null) {
|
|
709
|
+
var ref = {
|
|
710
|
+
current: initialValue
|
|
711
|
+
};
|
|
788
712
|
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
return previousRef;
|
|
793
|
-
}
|
|
794
|
-
};
|
|
795
|
-
|
|
796
|
-
var readContext = function (context, observedBits) {
|
|
797
|
-
return context._currentValue;
|
|
798
|
-
};
|
|
713
|
+
{
|
|
714
|
+
Object.seal(ref);
|
|
715
|
+
}
|
|
799
716
|
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
717
|
+
_this._workInProgressHook.memoizedState = ref;
|
|
718
|
+
return ref;
|
|
719
|
+
} else {
|
|
720
|
+
return previousRef;
|
|
721
|
+
}
|
|
722
|
+
};
|
|
803
723
|
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
724
|
+
var readContext = function (context, observedBits) {
|
|
725
|
+
return context._currentValue;
|
|
726
|
+
};
|
|
807
727
|
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
props: props,
|
|
811
|
-
responder: responder
|
|
728
|
+
var noOp = function () {
|
|
729
|
+
_this._validateCurrentlyRenderingComponent();
|
|
812
730
|
};
|
|
813
|
-
}; // TODO: implement if we decide to keep the shallow renderer
|
|
814
731
|
|
|
732
|
+
var identity = function (fn) {
|
|
733
|
+
return fn;
|
|
734
|
+
};
|
|
815
735
|
|
|
816
|
-
|
|
817
|
-
|
|
736
|
+
var useResponder = function (responder, props) {
|
|
737
|
+
return {
|
|
738
|
+
props: props,
|
|
739
|
+
responder: responder
|
|
740
|
+
};
|
|
741
|
+
}; // TODO: implement if we decide to keep the shallow renderer
|
|
818
742
|
|
|
819
|
-
var startTransition = function (callback) {
|
|
820
|
-
callback();
|
|
821
|
-
};
|
|
822
743
|
|
|
823
|
-
|
|
824
|
-
|
|
744
|
+
var useTransition = function (config) {
|
|
745
|
+
_this._validateCurrentlyRenderingComponent();
|
|
825
746
|
|
|
747
|
+
var startTransition = function (callback) {
|
|
748
|
+
callback();
|
|
749
|
+
};
|
|
826
750
|
|
|
827
|
-
|
|
828
|
-
|
|
751
|
+
return [startTransition, false];
|
|
752
|
+
}; // TODO: implement if we decide to keep the shallow renderer
|
|
829
753
|
|
|
830
|
-
return value;
|
|
831
|
-
};
|
|
832
754
|
|
|
833
|
-
|
|
834
|
-
readContext: readContext,
|
|
835
|
-
useCallback: identity,
|
|
836
|
-
useContext: function (context) {
|
|
755
|
+
var useDeferredValue = function (value, config) {
|
|
837
756
|
_this._validateCurrentlyRenderingComponent();
|
|
838
757
|
|
|
839
|
-
return
|
|
840
|
-
}
|
|
841
|
-
useDebugValue: noOp,
|
|
842
|
-
useEffect: noOp,
|
|
843
|
-
useImperativeHandle: noOp,
|
|
844
|
-
useLayoutEffect: noOp,
|
|
845
|
-
useMemo: useMemo,
|
|
846
|
-
useReducer: useReducer,
|
|
847
|
-
useRef: useRef,
|
|
848
|
-
useState: useState,
|
|
849
|
-
useResponder: useResponder,
|
|
850
|
-
useTransition: useTransition,
|
|
851
|
-
useDeferredValue: useDeferredValue
|
|
852
|
-
};
|
|
853
|
-
};
|
|
854
|
-
|
|
855
|
-
_proto2._dispatchAction = function _dispatchAction(queue, action) {
|
|
856
|
-
if (!(this._numberOfReRenders < RE_RENDER_LIMIT)) {
|
|
857
|
-
{
|
|
858
|
-
throw Error("Too many re-renders. React limits the number of renders to prevent an infinite loop.");
|
|
859
|
-
}
|
|
860
|
-
}
|
|
758
|
+
return value;
|
|
759
|
+
};
|
|
861
760
|
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
761
|
+
return {
|
|
762
|
+
readContext: readContext,
|
|
763
|
+
useCallback: identity,
|
|
764
|
+
useContext: function (context) {
|
|
765
|
+
_this._validateCurrentlyRenderingComponent();
|
|
766
|
+
|
|
767
|
+
return readContext(context);
|
|
768
|
+
},
|
|
769
|
+
useDebugValue: noOp,
|
|
770
|
+
useEffect: noOp,
|
|
771
|
+
useImperativeHandle: noOp,
|
|
772
|
+
useLayoutEffect: noOp,
|
|
773
|
+
useMemo: useMemo,
|
|
774
|
+
useReducer: useReducer,
|
|
775
|
+
useRef: useRef,
|
|
776
|
+
useState: useState,
|
|
777
|
+
useResponder: useResponder,
|
|
778
|
+
useTransition: useTransition,
|
|
779
|
+
useDeferredValue: useDeferredValue
|
|
870
780
|
};
|
|
871
|
-
|
|
781
|
+
};
|
|
872
782
|
|
|
873
|
-
|
|
874
|
-
|
|
783
|
+
_proto2._dispatchAction = function _dispatchAction(queue, action) {
|
|
784
|
+
if (!(this._numberOfReRenders < RE_RENDER_LIMIT)) {
|
|
785
|
+
{
|
|
786
|
+
throw Error( "Too many re-renders. React limits the number of renders to prevent an infinite loop." );
|
|
787
|
+
}
|
|
875
788
|
}
|
|
876
789
|
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
790
|
+
if (this._rendering) {
|
|
791
|
+
// This is a render phase update. Stash it in a lazily-created map of
|
|
792
|
+
// queue -> linked list of updates. After this render pass, we'll restart
|
|
793
|
+
// and apply the stashed updates on top of the work-in-progress hook.
|
|
794
|
+
this._didScheduleRenderPhaseUpdate = true;
|
|
795
|
+
var update = {
|
|
796
|
+
action: action,
|
|
797
|
+
next: null
|
|
798
|
+
};
|
|
799
|
+
var renderPhaseUpdates = this._renderPhaseUpdates;
|
|
884
800
|
|
|
885
|
-
|
|
886
|
-
|
|
801
|
+
if (renderPhaseUpdates === null) {
|
|
802
|
+
this._renderPhaseUpdates = renderPhaseUpdates = new Map();
|
|
887
803
|
}
|
|
888
804
|
|
|
889
|
-
|
|
890
|
-
}
|
|
891
|
-
} else {
|
|
892
|
-
var _update2 = {
|
|
893
|
-
action: action,
|
|
894
|
-
next: null
|
|
895
|
-
}; // Append the update to the end of the list.
|
|
805
|
+
var firstRenderPhaseUpdate = renderPhaseUpdates.get(queue);
|
|
896
806
|
|
|
897
|
-
|
|
807
|
+
if (firstRenderPhaseUpdate === undefined) {
|
|
808
|
+
renderPhaseUpdates.set(queue, update);
|
|
809
|
+
} else {
|
|
810
|
+
// Append the update to the end of the list.
|
|
811
|
+
var lastRenderPhaseUpdate = firstRenderPhaseUpdate;
|
|
898
812
|
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
813
|
+
while (lastRenderPhaseUpdate.next !== null) {
|
|
814
|
+
lastRenderPhaseUpdate = lastRenderPhaseUpdate.next;
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
lastRenderPhaseUpdate.next = update;
|
|
904
818
|
}
|
|
819
|
+
} else {
|
|
820
|
+
var _update2 = {
|
|
821
|
+
action: action,
|
|
822
|
+
next: null
|
|
823
|
+
}; // Append the update to the end of the list.
|
|
824
|
+
|
|
825
|
+
var last = queue.first;
|
|
905
826
|
|
|
906
|
-
last
|
|
907
|
-
|
|
827
|
+
if (last === null) {
|
|
828
|
+
queue.first = _update2;
|
|
829
|
+
} else {
|
|
830
|
+
while (last.next !== null) {
|
|
831
|
+
last = last.next;
|
|
832
|
+
}
|
|
908
833
|
|
|
834
|
+
last.next = _update2;
|
|
835
|
+
} // Re-render now.
|
|
909
836
|
|
|
910
|
-
this.render(this._element, this._context);
|
|
911
|
-
}
|
|
912
|
-
};
|
|
913
837
|
|
|
914
|
-
|
|
915
|
-
if (this._workInProgressHook === null) {
|
|
916
|
-
// This is the first hook in the list
|
|
917
|
-
if (this._firstWorkInProgressHook === null) {
|
|
918
|
-
this._isReRender = false;
|
|
919
|
-
this._firstWorkInProgressHook = this._workInProgressHook = createHook();
|
|
920
|
-
} else {
|
|
921
|
-
// There's already a work-in-progress. Reuse it.
|
|
922
|
-
this._isReRender = true;
|
|
923
|
-
this._workInProgressHook = this._firstWorkInProgressHook;
|
|
838
|
+
this.render(this._element, this._context);
|
|
924
839
|
}
|
|
925
|
-
}
|
|
926
|
-
if (this._workInProgressHook.next === null) {
|
|
927
|
-
this._isReRender = false; // Append to the end of the list
|
|
840
|
+
};
|
|
928
841
|
|
|
929
|
-
|
|
842
|
+
_proto2._createWorkInProgressHook = function _createWorkInProgressHook() {
|
|
843
|
+
if (this._workInProgressHook === null) {
|
|
844
|
+
// This is the first hook in the list
|
|
845
|
+
if (this._firstWorkInProgressHook === null) {
|
|
846
|
+
this._isReRender = false;
|
|
847
|
+
this._firstWorkInProgressHook = this._workInProgressHook = createHook();
|
|
848
|
+
} else {
|
|
849
|
+
// There's already a work-in-progress. Reuse it.
|
|
850
|
+
this._isReRender = true;
|
|
851
|
+
this._workInProgressHook = this._firstWorkInProgressHook;
|
|
852
|
+
}
|
|
930
853
|
} else {
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
this._workInProgressHook = this._workInProgressHook.next;
|
|
934
|
-
}
|
|
935
|
-
}
|
|
854
|
+
if (this._workInProgressHook.next === null) {
|
|
855
|
+
this._isReRender = false; // Append to the end of the list
|
|
936
856
|
|
|
937
|
-
|
|
938
|
-
|
|
857
|
+
this._workInProgressHook = this._workInProgressHook.next = createHook();
|
|
858
|
+
} else {
|
|
859
|
+
// There's already a work-in-progress. Reuse it.
|
|
860
|
+
this._isReRender = true;
|
|
861
|
+
this._workInProgressHook = this._workInProgressHook.next;
|
|
862
|
+
}
|
|
863
|
+
}
|
|
939
864
|
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
// Updates were scheduled during the render phase. They are stored in
|
|
943
|
-
// the `renderPhaseUpdates` map. Call the component again, reusing the
|
|
944
|
-
// work-in-progress hooks and applying the additional updates on top. Keep
|
|
945
|
-
// restarting until no more updates are scheduled.
|
|
946
|
-
this._didScheduleRenderPhaseUpdate = false;
|
|
947
|
-
this._numberOfReRenders += 1; // Start over from the beginning of the list
|
|
865
|
+
return this._workInProgressHook;
|
|
866
|
+
};
|
|
948
867
|
|
|
949
|
-
|
|
950
|
-
this.
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
868
|
+
_proto2._finishHooks = function _finishHooks(element, context) {
|
|
869
|
+
if (this._didScheduleRenderPhaseUpdate) {
|
|
870
|
+
// Updates were scheduled during the render phase. They are stored in
|
|
871
|
+
// the `renderPhaseUpdates` map. Call the component again, reusing the
|
|
872
|
+
// work-in-progress hooks and applying the additional updates on top. Keep
|
|
873
|
+
// restarting until no more updates are scheduled.
|
|
874
|
+
this._didScheduleRenderPhaseUpdate = false;
|
|
875
|
+
this._numberOfReRenders += 1; // Start over from the beginning of the list
|
|
876
|
+
|
|
877
|
+
this._workInProgressHook = null;
|
|
878
|
+
this._rendering = false;
|
|
879
|
+
this.render(element, context);
|
|
880
|
+
} else {
|
|
881
|
+
this._workInProgressHook = null;
|
|
882
|
+
this._renderPhaseUpdates = null;
|
|
883
|
+
this._numberOfReRenders = 0;
|
|
884
|
+
}
|
|
885
|
+
};
|
|
958
886
|
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
887
|
+
_proto2.getMountedInstance = function getMountedInstance() {
|
|
888
|
+
return this._instance;
|
|
889
|
+
};
|
|
962
890
|
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
891
|
+
_proto2.getRenderOutput = function getRenderOutput() {
|
|
892
|
+
return this._rendered;
|
|
893
|
+
};
|
|
966
894
|
|
|
967
|
-
|
|
968
|
-
|
|
895
|
+
_proto2.render = function render(element) {
|
|
896
|
+
var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : emptyObject;
|
|
969
897
|
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
898
|
+
if (!React.isValidElement(element)) {
|
|
899
|
+
{
|
|
900
|
+
throw Error( "ReactShallowRenderer render(): Invalid component element." + (typeof element === 'function' ? ' Instead of passing a component class, make sure to instantiate ' + 'it by passing it to React.createElement.' : '') );
|
|
901
|
+
}
|
|
973
902
|
}
|
|
974
|
-
}
|
|
975
903
|
|
|
976
|
-
|
|
904
|
+
element = element; // Show a special message for host elements since it's a common case.
|
|
977
905
|
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
906
|
+
if (!(typeof element.type !== 'string')) {
|
|
907
|
+
{
|
|
908
|
+
throw Error( "ReactShallowRenderer render(): Shallow rendering works only with custom components, not primitives (" + element.type + "). Instead of calling `.render(el)` and inspecting the rendered output, look at `el.props` directly instead." );
|
|
909
|
+
}
|
|
981
910
|
}
|
|
982
|
-
}
|
|
983
911
|
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
912
|
+
if (!(isForwardRef(element) || typeof element.type === 'function' || isMemo(element))) {
|
|
913
|
+
{
|
|
914
|
+
throw Error( "ReactShallowRenderer render(): Shallow rendering works only with custom components, but the provided element type was `" + (Array.isArray(element.type) ? 'array' : element.type === null ? 'null' : typeof element.type) + "`." );
|
|
915
|
+
}
|
|
987
916
|
}
|
|
988
|
-
}
|
|
989
917
|
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
918
|
+
if (this._rendering) {
|
|
919
|
+
return;
|
|
920
|
+
}
|
|
993
921
|
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
922
|
+
if (this._element != null && this._element.type !== element.type) {
|
|
923
|
+
this._reset();
|
|
924
|
+
}
|
|
997
925
|
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
926
|
+
var elementType = isMemo(element) ? element.type.type : element.type;
|
|
927
|
+
var previousElement = this._element;
|
|
928
|
+
this._rendering = true;
|
|
929
|
+
this._element = element;
|
|
930
|
+
this._context = getMaskedContext(elementType.contextTypes, context); // Inner memo component props aren't currently validated in createElement.
|
|
1003
931
|
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
932
|
+
if (isMemo(element) && elementType.propTypes) {
|
|
933
|
+
currentlyValidatingElement = element;
|
|
934
|
+
checkPropTypes_1(elementType.propTypes, element.props, 'prop', getComponentName(elementType), getStackAddendum);
|
|
935
|
+
}
|
|
1008
936
|
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
937
|
+
if (this._instance) {
|
|
938
|
+
this._updateClassComponent(elementType, element, this._context);
|
|
939
|
+
} else {
|
|
940
|
+
if (shouldConstruct(elementType)) {
|
|
941
|
+
this._instance = new elementType(element.props, this._context, this._updater);
|
|
1014
942
|
|
|
1015
|
-
|
|
1016
|
-
|
|
943
|
+
if (typeof elementType.getDerivedStateFromProps === 'function') {
|
|
944
|
+
var partialState = elementType.getDerivedStateFromProps.call(null, element.props, this._instance.state);
|
|
1017
945
|
|
|
1018
|
-
|
|
1019
|
-
|
|
946
|
+
if (partialState != null) {
|
|
947
|
+
this._instance.state = _assign({}, this._instance.state, partialState);
|
|
948
|
+
}
|
|
1020
949
|
}
|
|
1021
|
-
}
|
|
1022
950
|
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
951
|
+
if (elementType.contextTypes) {
|
|
952
|
+
currentlyValidatingElement = element;
|
|
953
|
+
checkPropTypes_1(elementType.contextTypes, this._context, 'context', getName(elementType, this._instance), getStackAddendum);
|
|
954
|
+
currentlyValidatingElement = null;
|
|
955
|
+
}
|
|
1028
956
|
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
957
|
+
this._mountClassComponent(elementType, element, this._context);
|
|
958
|
+
} else {
|
|
959
|
+
var shouldRender = true;
|
|
1032
960
|
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
961
|
+
if (isMemo(element) && previousElement !== null) {
|
|
962
|
+
// This is a Memo component that is being re-rendered.
|
|
963
|
+
var compare = element.type.compare || shallowEqual;
|
|
1036
964
|
|
|
1037
|
-
|
|
1038
|
-
|
|
965
|
+
if (compare(previousElement.props, element.props)) {
|
|
966
|
+
shouldRender = false;
|
|
967
|
+
}
|
|
1039
968
|
}
|
|
1040
|
-
}
|
|
1041
|
-
|
|
1042
|
-
if (shouldRender) {
|
|
1043
|
-
var prevDispatcher = ReactCurrentDispatcher.current;
|
|
1044
|
-
ReactCurrentDispatcher.current = this._dispatcher;
|
|
1045
969
|
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
970
|
+
if (shouldRender) {
|
|
971
|
+
var prevDispatcher = ReactCurrentDispatcher.current;
|
|
972
|
+
ReactCurrentDispatcher.current = this._dispatcher;
|
|
973
|
+
|
|
974
|
+
try {
|
|
975
|
+
// elementType could still be a ForwardRef if it was
|
|
976
|
+
// nested inside Memo.
|
|
977
|
+
if (elementType.$$typeof === ForwardRef) {
|
|
978
|
+
if (!(typeof elementType.render === 'function')) {
|
|
979
|
+
{
|
|
980
|
+
throw Error(true ? "forwardRef requires a render function but was given " + typeof elementType.render + "." : formatProdErrorMessage(322, typeof elementType.render));
|
|
981
|
+
}
|
|
1053
982
|
}
|
|
1054
|
-
}
|
|
1055
983
|
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
984
|
+
this._rendered = elementType.render.call(undefined, element.props, element.ref);
|
|
985
|
+
} else {
|
|
986
|
+
this._rendered = elementType(element.props, this._context);
|
|
987
|
+
}
|
|
988
|
+
} finally {
|
|
989
|
+
ReactCurrentDispatcher.current = prevDispatcher;
|
|
1059
990
|
}
|
|
1060
|
-
} finally {
|
|
1061
|
-
ReactCurrentDispatcher.current = prevDispatcher;
|
|
1062
|
-
}
|
|
1063
991
|
|
|
1064
|
-
|
|
992
|
+
this._finishHooks(element, context);
|
|
993
|
+
}
|
|
1065
994
|
}
|
|
1066
995
|
}
|
|
1067
|
-
}
|
|
1068
996
|
|
|
1069
|
-
|
|
997
|
+
this._rendering = false;
|
|
1070
998
|
|
|
1071
|
-
|
|
999
|
+
this._updater._invokeCallbacks();
|
|
1072
1000
|
|
|
1073
|
-
|
|
1074
|
-
|
|
1001
|
+
return this.getRenderOutput();
|
|
1002
|
+
};
|
|
1075
1003
|
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1004
|
+
_proto2.unmount = function unmount() {
|
|
1005
|
+
if (this._instance) {
|
|
1006
|
+
if (typeof this._instance.componentWillUnmount === 'function') {
|
|
1007
|
+
this._instance.componentWillUnmount();
|
|
1008
|
+
}
|
|
1080
1009
|
}
|
|
1081
|
-
}
|
|
1082
1010
|
|
|
1083
|
-
|
|
1084
|
-
|
|
1011
|
+
this._reset();
|
|
1012
|
+
};
|
|
1085
1013
|
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1014
|
+
_proto2._mountClassComponent = function _mountClassComponent(elementType, element, context) {
|
|
1015
|
+
this._instance.context = context;
|
|
1016
|
+
this._instance.props = element.props;
|
|
1017
|
+
this._instance.state = this._instance.state || null;
|
|
1018
|
+
this._instance.updater = this._updater;
|
|
1091
1019
|
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1020
|
+
if (typeof this._instance.UNSAFE_componentWillMount === 'function' || typeof this._instance.componentWillMount === 'function') {
|
|
1021
|
+
var beforeState = this._newState; // In order to support react-lifecycles-compat polyfilled components,
|
|
1022
|
+
// Unsafe lifecycles should not be invoked for components using the new APIs.
|
|
1095
1023
|
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1024
|
+
if (typeof elementType.getDerivedStateFromProps !== 'function' && typeof this._instance.getSnapshotBeforeUpdate !== 'function') {
|
|
1025
|
+
if (typeof this._instance.componentWillMount === 'function') {
|
|
1026
|
+
this._instance.componentWillMount();
|
|
1027
|
+
}
|
|
1100
1028
|
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1029
|
+
if (typeof this._instance.UNSAFE_componentWillMount === 'function') {
|
|
1030
|
+
this._instance.UNSAFE_componentWillMount();
|
|
1031
|
+
}
|
|
1032
|
+
} // setState may have been called during cWM
|
|
1105
1033
|
|
|
1106
1034
|
|
|
1107
|
-
|
|
1108
|
-
|
|
1035
|
+
if (beforeState !== this._newState) {
|
|
1036
|
+
this._instance.state = this._newState || emptyObject;
|
|
1037
|
+
}
|
|
1109
1038
|
}
|
|
1110
|
-
}
|
|
1111
1039
|
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1040
|
+
this._rendered = this._instance.render(); // Intentionally do not call componentDidMount()
|
|
1041
|
+
// because DOM refs are not available.
|
|
1042
|
+
};
|
|
1115
1043
|
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1044
|
+
_proto2._updateClassComponent = function _updateClassComponent(elementType, element, context) {
|
|
1045
|
+
var props = element.props;
|
|
1046
|
+
var oldState = this._instance.state || emptyObject;
|
|
1047
|
+
var oldProps = this._instance.props;
|
|
1048
|
+
|
|
1049
|
+
if (oldProps !== props) {
|
|
1050
|
+
// In order to support react-lifecycles-compat polyfilled components,
|
|
1051
|
+
// Unsafe lifecycles should not be invoked for components using the new APIs.
|
|
1052
|
+
if (typeof elementType.getDerivedStateFromProps !== 'function' && typeof this._instance.getSnapshotBeforeUpdate !== 'function') {
|
|
1053
|
+
if (typeof this._instance.componentWillReceiveProps === 'function') {
|
|
1054
|
+
this._instance.componentWillReceiveProps(props, context);
|
|
1055
|
+
}
|
|
1128
1056
|
|
|
1129
|
-
|
|
1130
|
-
|
|
1057
|
+
if (typeof this._instance.UNSAFE_componentWillReceiveProps === 'function') {
|
|
1058
|
+
this._instance.UNSAFE_componentWillReceiveProps(props, context);
|
|
1059
|
+
}
|
|
1131
1060
|
}
|
|
1132
|
-
}
|
|
1133
|
-
} // Read state after cWRP in case it calls setState
|
|
1061
|
+
} // Read state after cWRP in case it calls setState
|
|
1134
1062
|
|
|
1135
1063
|
|
|
1136
|
-
|
|
1064
|
+
var state = this._newState || oldState;
|
|
1137
1065
|
|
|
1138
|
-
|
|
1139
|
-
|
|
1066
|
+
if (typeof elementType.getDerivedStateFromProps === 'function') {
|
|
1067
|
+
var partialState = elementType.getDerivedStateFromProps.call(null, props, state);
|
|
1140
1068
|
|
|
1141
|
-
|
|
1142
|
-
|
|
1069
|
+
if (partialState != null) {
|
|
1070
|
+
state = _assign({}, state, partialState);
|
|
1071
|
+
}
|
|
1143
1072
|
}
|
|
1144
|
-
}
|
|
1145
1073
|
|
|
1146
|
-
|
|
1074
|
+
var shouldUpdate = true;
|
|
1147
1075
|
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1076
|
+
if (this._forcedUpdate) {
|
|
1077
|
+
shouldUpdate = true;
|
|
1078
|
+
this._forcedUpdate = false;
|
|
1079
|
+
} else if (typeof this._instance.shouldComponentUpdate === 'function') {
|
|
1080
|
+
shouldUpdate = !!this._instance.shouldComponentUpdate(props, state, context);
|
|
1081
|
+
} else if (elementType.prototype && elementType.prototype.isPureReactComponent) {
|
|
1082
|
+
shouldUpdate = !shallowEqual(oldProps, props) || !shallowEqual(oldState, state);
|
|
1083
|
+
}
|
|
1156
1084
|
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1085
|
+
if (shouldUpdate) {
|
|
1086
|
+
// In order to support react-lifecycles-compat polyfilled components,
|
|
1087
|
+
// Unsafe lifecycles should not be invoked for components using the new APIs.
|
|
1088
|
+
if (typeof elementType.getDerivedStateFromProps !== 'function' && typeof this._instance.getSnapshotBeforeUpdate !== 'function') {
|
|
1089
|
+
if (typeof this._instance.componentWillUpdate === 'function') {
|
|
1090
|
+
this._instance.componentWillUpdate(props, state, context);
|
|
1091
|
+
}
|
|
1164
1092
|
|
|
1165
|
-
|
|
1166
|
-
|
|
1093
|
+
if (typeof this._instance.UNSAFE_componentWillUpdate === 'function') {
|
|
1094
|
+
this._instance.UNSAFE_componentWillUpdate(props, state, context);
|
|
1095
|
+
}
|
|
1167
1096
|
}
|
|
1168
1097
|
}
|
|
1169
|
-
}
|
|
1170
1098
|
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1099
|
+
this._instance.context = context;
|
|
1100
|
+
this._instance.props = props;
|
|
1101
|
+
this._instance.state = state;
|
|
1102
|
+
this._newState = null;
|
|
1175
1103
|
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1104
|
+
if (shouldUpdate) {
|
|
1105
|
+
this._rendered = this._instance.render();
|
|
1106
|
+
} // Intentionally do not call componentDidUpdate()
|
|
1107
|
+
// because DOM refs are not available.
|
|
1180
1108
|
|
|
1181
|
-
|
|
1109
|
+
};
|
|
1182
1110
|
|
|
1183
|
-
|
|
1184
|
-
}();
|
|
1185
|
-
|
|
1186
|
-
ReactShallowRenderer.createRenderer = function () {
|
|
1187
|
-
return new ReactShallowRenderer();
|
|
1188
|
-
};
|
|
1189
|
-
|
|
1190
|
-
var currentlyValidatingElement = null;
|
|
1191
|
-
|
|
1192
|
-
function getDisplayName(element) {
|
|
1193
|
-
if (element == null) {
|
|
1194
|
-
return '#empty';
|
|
1195
|
-
} else if (typeof element === 'string' || typeof element === 'number') {
|
|
1196
|
-
return '#text';
|
|
1197
|
-
} else if (typeof element.type === 'string') {
|
|
1198
|
-
return element.type;
|
|
1199
|
-
} else {
|
|
1200
|
-
var elementType = isMemo(element) ? element.type.type : element.type;
|
|
1201
|
-
return elementType.displayName || elementType.name || 'Unknown';
|
|
1202
|
-
}
|
|
1203
|
-
}
|
|
1111
|
+
return ReactShallowRenderer;
|
|
1112
|
+
}();
|
|
1204
1113
|
|
|
1205
|
-
function
|
|
1206
|
-
|
|
1114
|
+
ReactShallowRenderer.createRenderer = function () {
|
|
1115
|
+
return new ReactShallowRenderer();
|
|
1116
|
+
};
|
|
1207
1117
|
|
|
1208
|
-
|
|
1209
|
-
var name = getDisplayName(currentlyValidatingElement);
|
|
1210
|
-
var owner = currentlyValidatingElement._owner;
|
|
1211
|
-
stack += describeComponentFrame(name, currentlyValidatingElement._source, owner && getComponentName(owner.type));
|
|
1212
|
-
}
|
|
1118
|
+
var currentlyValidatingElement = null;
|
|
1213
1119
|
|
|
1214
|
-
|
|
1215
|
-
|
|
1120
|
+
function getDisplayName(element) {
|
|
1121
|
+
if (element == null) {
|
|
1122
|
+
return '#empty';
|
|
1123
|
+
} else if (typeof element === 'string' || typeof element === 'number') {
|
|
1124
|
+
return '#text';
|
|
1125
|
+
} else if (typeof element.type === 'string') {
|
|
1126
|
+
return element.type;
|
|
1127
|
+
} else {
|
|
1128
|
+
var elementType = isMemo(element) ? element.type.type : element.type;
|
|
1129
|
+
return elementType.displayName || elementType.name || 'Unknown';
|
|
1130
|
+
}
|
|
1131
|
+
}
|
|
1216
1132
|
|
|
1217
|
-
function
|
|
1218
|
-
|
|
1219
|
-
return type.displayName || constructor && constructor.displayName || type.name || constructor && constructor.name || null;
|
|
1220
|
-
}
|
|
1133
|
+
function getStackAddendum() {
|
|
1134
|
+
var stack = '';
|
|
1221
1135
|
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1136
|
+
if (currentlyValidatingElement) {
|
|
1137
|
+
var name = getDisplayName(currentlyValidatingElement);
|
|
1138
|
+
var owner = currentlyValidatingElement._owner;
|
|
1139
|
+
stack += describeComponentFrame(name, currentlyValidatingElement._source, owner && getComponentName(owner.type));
|
|
1140
|
+
}
|
|
1225
1141
|
|
|
1226
|
-
|
|
1227
|
-
if (!contextTypes || !unmaskedContext) {
|
|
1228
|
-
return emptyObject;
|
|
1142
|
+
return stack;
|
|
1229
1143
|
}
|
|
1230
1144
|
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
context[key] = unmaskedContext[key];
|
|
1145
|
+
function getName(type, instance) {
|
|
1146
|
+
var constructor = instance && instance.constructor;
|
|
1147
|
+
return type.displayName || constructor && constructor.displayName || type.name || constructor && constructor.name || null;
|
|
1235
1148
|
}
|
|
1236
1149
|
|
|
1237
|
-
|
|
1238
|
-
|
|
1150
|
+
function shouldConstruct(Component) {
|
|
1151
|
+
return !!(Component.prototype && Component.prototype.isReactComponent);
|
|
1152
|
+
}
|
|
1239
1153
|
|
|
1154
|
+
function getMaskedContext(contextTypes, unmaskedContext) {
|
|
1155
|
+
if (!contextTypes || !unmaskedContext) {
|
|
1156
|
+
return emptyObject;
|
|
1157
|
+
}
|
|
1240
1158
|
|
|
1159
|
+
var context = {};
|
|
1241
1160
|
|
|
1242
|
-
var
|
|
1243
|
-
|
|
1244
|
-
}
|
|
1161
|
+
for (var key in contextTypes) {
|
|
1162
|
+
context[key] = unmaskedContext[key];
|
|
1163
|
+
}
|
|
1245
1164
|
|
|
1246
|
-
|
|
1165
|
+
return context;
|
|
1166
|
+
}
|
|
1247
1167
|
|
|
1248
|
-
// TODO: decide on the top-level export form.
|
|
1249
|
-
// This is hacky but makes it work with both Rollup and Jest.
|
|
1168
|
+
// TODO: decide on the top-level export form.
|
|
1169
|
+
// This is hacky but makes it work with both Rollup and Jest.
|
|
1250
1170
|
|
|
1251
1171
|
|
|
1252
|
-
var shallow = ReactShallowRenderer
|
|
1172
|
+
var shallow = ReactShallowRenderer.default || ReactShallowRenderer;
|
|
1253
1173
|
|
|
1254
|
-
return shallow;
|
|
1174
|
+
return shallow;
|
|
1255
1175
|
|
|
1256
1176
|
})));
|