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