react-dom 16.8.0-alpha.0 → 16.8.2

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.
Files changed (34) hide show
  1. package/build-info.json +6 -6
  2. package/cjs/react-dom-server.browser.development.js +169 -80
  3. package/cjs/react-dom-server.browser.production.min.js +35 -34
  4. package/cjs/react-dom-server.node.development.js +169 -80
  5. package/cjs/react-dom-server.node.production.min.js +35 -34
  6. package/cjs/react-dom-test-utils.development.js +52 -3
  7. package/cjs/react-dom-test-utils.production.min.js +23 -23
  8. package/cjs/react-dom-unstable-fire.development.js +4081 -3078
  9. package/cjs/react-dom-unstable-fire.production.min.js +254 -245
  10. package/cjs/react-dom-unstable-fire.profiling.min.js +230 -225
  11. package/cjs/react-dom-unstable-fizz.browser.development.js +1 -1
  12. package/cjs/react-dom-unstable-fizz.browser.production.min.js +1 -1
  13. package/cjs/react-dom-unstable-fizz.node.development.js +1 -1
  14. package/cjs/react-dom-unstable-fizz.node.production.min.js +1 -1
  15. package/cjs/react-dom-unstable-native-dependencies.development.js +2 -2
  16. package/cjs/react-dom-unstable-native-dependencies.production.min.js +1 -1
  17. package/cjs/react-dom.development.js +4078 -3076
  18. package/cjs/react-dom.production.min.js +254 -245
  19. package/cjs/react-dom.profiling.min.js +230 -225
  20. package/package.json +24 -52
  21. package/umd/react-dom-server.browser.development.js +169 -80
  22. package/umd/react-dom-server.browser.production.min.js +32 -32
  23. package/umd/react-dom-test-utils.development.js +52 -3
  24. package/umd/react-dom-test-utils.production.min.js +22 -21
  25. package/umd/react-dom-unstable-fire.development.js +4089 -3078
  26. package/umd/react-dom-unstable-fire.production.min.js +208 -202
  27. package/umd/react-dom-unstable-fire.profiling.min.js +212 -208
  28. package/umd/react-dom-unstable-fizz.browser.development.js +1 -1
  29. package/umd/react-dom-unstable-fizz.browser.production.min.js +1 -1
  30. package/umd/react-dom-unstable-native-dependencies.development.js +2 -2
  31. package/umd/react-dom-unstable-native-dependencies.production.min.js +1 -1
  32. package/umd/react-dom.development.js +4086 -3076
  33. package/umd/react-dom.production.min.js +208 -202
  34. package/umd/react-dom.profiling.min.js +212 -208
@@ -1,4 +1,4 @@
1
- /** @license React v16.8.0-alpha.0
1
+ /** @license React v16.8.2
2
2
  * react-dom-server.node.development.js
3
3
  *
4
4
  * Copyright (c) Facebook, Inc. and its affiliates.
@@ -22,7 +22,7 @@ var stream = require('stream');
22
22
 
23
23
  // TODO: this is special because it gets imported during build.
24
24
 
25
- var ReactVersion = '16.8.0-alpha.0';
25
+ var ReactVersion = '16.8.2';
26
26
 
27
27
  /**
28
28
  * Use invariant() to assert state which your program assumes to be true.
@@ -257,6 +257,15 @@ var lowPriorityWarning$1 = lowPriorityWarning;
257
257
 
258
258
  var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
259
259
 
260
+ // Prevent newer renderers from RTE when used with older react package versions.
261
+ // Current owner and dispatcher used to share the same ref,
262
+ // but PR #14548 split them out to better support the react-debug-tools package.
263
+ if (!ReactSharedInternals.hasOwnProperty('ReactCurrentDispatcher')) {
264
+ ReactSharedInternals.ReactCurrentDispatcher = {
265
+ current: null
266
+ };
267
+ }
268
+
260
269
  /**
261
270
  * Similar to invariant but only logs a warning if the condition is not met.
262
271
  * This can be used to log issues in development environments in critical
@@ -313,7 +322,6 @@ var describeComponentFrame = function (name, source, ownerName) {
313
322
  return '\n in ' + (name || 'Unknown') + sourceInfo;
314
323
  };
315
324
 
316
- var enableHooks = true;
317
325
  // Helps identify side effects in begin-phase lifecycle hooks and setState reducers:
318
326
 
319
327
 
@@ -734,12 +742,15 @@ var capitalize = function (token) {
734
742
  attributeName, 'http://www.w3.org/XML/1998/namespace');
735
743
  });
736
744
 
737
- // Special case: this attribute exists both in HTML and SVG.
738
- // Its "tabindex" attribute name is case-sensitive in SVG so we can't just use
739
- // its React `tabIndex` name, like we do for attributes that exist only in HTML.
740
- properties.tabIndex = new PropertyInfoRecord('tabIndex', STRING, false, // mustUseProperty
741
- 'tabindex', // attributeName
742
- null);
745
+ // These attribute exists both in HTML and SVG.
746
+ // The attribute name is case-sensitive in SVG so we can't just use
747
+ // the React name like we do for attributes that exist only in HTML.
748
+ ['tabIndex', 'crossOrigin'].forEach(function (attributeName) {
749
+ properties[attributeName] = new PropertyInfoRecord(attributeName, STRING, false, // mustUseProperty
750
+ attributeName.toLowerCase(), // attributeName
751
+ null);
752
+ } // attributeNamespace
753
+ );
743
754
 
744
755
  // code copied and modified from escape-html
745
756
  /**
@@ -903,21 +914,6 @@ function is(x, y) {
903
914
  ;
904
915
  }
905
916
 
906
- function areHookInputsEqual(arr1, arr2) {
907
- // Don't bother comparing lengths in prod because these arrays should be
908
- // passed inline.
909
- {
910
- !(arr1.length === arr2.length) ? warning$1(false, 'Detected a variable number of hook dependencies. The length of the ' + 'dependencies array should be constant between renders.\n\n' + 'Previous: %s\n' + 'Incoming: %s', arr1.join(', '), arr2.join(', ')) : void 0;
911
- }
912
- for (var i = 0; i < arr1.length; i++) {
913
- if (is(arr1[i], arr2[i])) {
914
- continue;
915
- }
916
- return false;
917
- }
918
- return true;
919
- }
920
-
921
917
  var currentlyRenderingComponent = null;
922
918
  var firstWorkInProgressHook = null;
923
919
  var workInProgressHook = null;
@@ -931,12 +927,47 @@ var renderPhaseUpdates = null;
931
927
  var numberOfReRenders = 0;
932
928
  var RE_RENDER_LIMIT = 25;
933
929
 
930
+ var isInHookUserCodeInDev = false;
931
+
932
+ // In DEV, this is the name of the currently executing primitive hook
933
+ var currentHookNameInDev = void 0;
934
+
934
935
  function resolveCurrentlyRenderingComponent() {
935
- !(currentlyRenderingComponent !== null) ? invariant(false, 'Hooks can only be called inside the body of a function component.') : void 0;
936
+ !(currentlyRenderingComponent !== null) ? invariant(false, 'Hooks can only be called inside the body of a function component. (https://fb.me/react-invalid-hook-call)') : void 0;
937
+ {
938
+ !!isInHookUserCodeInDev ? warning$1(false, 'Do not call Hooks inside useEffect(...), useMemo(...), or other built-in Hooks. ' + 'You can only call Hooks at the top level of your React function. ' + 'For more information, see ' + 'https://fb.me/rules-of-hooks') : void 0;
939
+ }
936
940
  return currentlyRenderingComponent;
937
941
  }
938
942
 
943
+ function areHookInputsEqual(nextDeps, prevDeps) {
944
+ if (prevDeps === null) {
945
+ {
946
+ 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);
947
+ }
948
+ return false;
949
+ }
950
+
951
+ {
952
+ // Don't bother comparing lengths in prod because these arrays should be
953
+ // passed inline.
954
+ if (nextDeps.length !== prevDeps.length) {
955
+ warning$1(false, '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(', ') + ']');
956
+ }
957
+ }
958
+ for (var i = 0; i < prevDeps.length && i < nextDeps.length; i++) {
959
+ if (is(nextDeps[i], prevDeps[i])) {
960
+ continue;
961
+ }
962
+ return false;
963
+ }
964
+ return true;
965
+ }
966
+
939
967
  function createHook() {
968
+ if (numberOfReRenders > 0) {
969
+ invariant(false, 'Rendered more hooks than during the previous render');
970
+ }
940
971
  return {
941
972
  memoizedState: null,
942
973
  queue: null,
@@ -971,6 +1002,9 @@ function createWorkInProgressHook() {
971
1002
 
972
1003
  function prepareToUseHooks(componentIdentity) {
973
1004
  currentlyRenderingComponent = componentIdentity;
1005
+ {
1006
+ isInHookUserCodeInDev = false;
1007
+ }
974
1008
 
975
1009
  // The following should have already been reset
976
1010
  // didScheduleRenderPhaseUpdate = false;
@@ -1002,6 +1036,9 @@ function finishHooks(Component, props, children, refOrContext) {
1002
1036
  numberOfReRenders = 0;
1003
1037
  renderPhaseUpdates = null;
1004
1038
  workInProgressHook = null;
1039
+ {
1040
+ isInHookUserCodeInDev = false;
1041
+ }
1005
1042
 
1006
1043
  // These were reset above
1007
1044
  // currentlyRenderingComponent = null;
@@ -1017,10 +1054,16 @@ function finishHooks(Component, props, children, refOrContext) {
1017
1054
  function readContext(context, observedBits) {
1018
1055
  var threadID = currentThreadID;
1019
1056
  validateContextBounds(context, threadID);
1057
+ {
1058
+ !!isInHookUserCodeInDev ? warning$1(false, 'Context can only be read while React is rendering. ' + 'In classes, you can read it in the render method or getDerivedStateFromProps. ' + 'In function components, you can read it directly in the function body, but not ' + 'inside Hooks like useReducer() or useMemo().') : void 0;
1059
+ }
1020
1060
  return context[threadID];
1021
1061
  }
1022
1062
 
1023
1063
  function useContext(context, observedBits) {
1064
+ {
1065
+ currentHookNameInDev = 'useContext';
1066
+ }
1024
1067
  resolveCurrentlyRenderingComponent();
1025
1068
  var threadID = currentThreadID;
1026
1069
  validateContextBounds(context, threadID);
@@ -1032,12 +1075,20 @@ function basicStateReducer(state, action) {
1032
1075
  }
1033
1076
 
1034
1077
  function useState(initialState) {
1078
+ {
1079
+ currentHookNameInDev = 'useState';
1080
+ }
1035
1081
  return useReducer(basicStateReducer,
1036
1082
  // useReducer has a special case to support lazy useState initializers
1037
1083
  initialState);
1038
1084
  }
1039
1085
 
1040
- function useReducer(reducer, initialState, initialAction) {
1086
+ function useReducer(reducer, initialArg, init) {
1087
+ {
1088
+ if (reducer !== basicStateReducer) {
1089
+ currentHookNameInDev = 'useReducer';
1090
+ }
1091
+ }
1041
1092
  currentlyRenderingComponent = resolveCurrentlyRenderingComponent();
1042
1093
  workInProgressHook = createWorkInProgressHook();
1043
1094
  if (isReRender) {
@@ -1056,7 +1107,13 @@ function useReducer(reducer, initialState, initialAction) {
1056
1107
  // priority because it will always be the same as the current
1057
1108
  // render's.
1058
1109
  var _action = update.action;
1110
+ {
1111
+ isInHookUserCodeInDev = true;
1112
+ }
1059
1113
  newState = reducer(newState, _action);
1114
+ {
1115
+ isInHookUserCodeInDev = false;
1116
+ }
1060
1117
  update = update.next;
1061
1118
  } while (update !== null);
1062
1119
 
@@ -1067,13 +1124,18 @@ function useReducer(reducer, initialState, initialAction) {
1067
1124
  }
1068
1125
  return [workInProgressHook.memoizedState, _dispatch];
1069
1126
  } else {
1127
+ {
1128
+ isInHookUserCodeInDev = true;
1129
+ }
1130
+ var initialState = void 0;
1070
1131
  if (reducer === basicStateReducer) {
1071
1132
  // Special case for `useState`.
1072
- if (typeof initialState === 'function') {
1073
- initialState = initialState();
1074
- }
1075
- } else if (initialAction !== undefined && initialAction !== null) {
1076
- initialState = reducer(initialState, initialAction);
1133
+ initialState = typeof initialArg === 'function' ? initialArg() : initialArg;
1134
+ } else {
1135
+ initialState = init !== undefined ? init(initialArg) : initialArg;
1136
+ }
1137
+ {
1138
+ isInHookUserCodeInDev = false;
1077
1139
  }
1078
1140
  workInProgressHook.memoizedState = initialState;
1079
1141
  var _queue2 = workInProgressHook.queue = {
@@ -1085,22 +1147,32 @@ function useReducer(reducer, initialState, initialAction) {
1085
1147
  }
1086
1148
  }
1087
1149
 
1088
- function useMemo(nextCreate, inputs) {
1150
+ function useMemo(nextCreate, deps) {
1089
1151
  currentlyRenderingComponent = resolveCurrentlyRenderingComponent();
1090
1152
  workInProgressHook = createWorkInProgressHook();
1091
1153
 
1092
- var nextInputs = inputs !== undefined && inputs !== null ? inputs : [nextCreate];
1154
+ var nextDeps = deps === undefined ? null : deps;
1093
1155
 
1094
- if (workInProgressHook !== null && workInProgressHook.memoizedState !== null) {
1156
+ if (workInProgressHook !== null) {
1095
1157
  var prevState = workInProgressHook.memoizedState;
1096
- var prevInputs = prevState[1];
1097
- if (areHookInputsEqual(nextInputs, prevInputs)) {
1098
- return prevState[0];
1158
+ if (prevState !== null) {
1159
+ if (nextDeps !== null) {
1160
+ var prevDeps = prevState[1];
1161
+ if (areHookInputsEqual(nextDeps, prevDeps)) {
1162
+ return prevState[0];
1163
+ }
1164
+ }
1099
1165
  }
1100
1166
  }
1101
1167
 
1168
+ {
1169
+ isInHookUserCodeInDev = true;
1170
+ }
1102
1171
  var nextValue = nextCreate();
1103
- workInProgressHook.memoizedState = [nextValue, nextInputs];
1172
+ {
1173
+ isInHookUserCodeInDev = false;
1174
+ }
1175
+ workInProgressHook.memoizedState = [nextValue, nextDeps];
1104
1176
  return nextValue;
1105
1177
  }
1106
1178
 
@@ -1121,6 +1193,9 @@ function useRef(initialValue) {
1121
1193
  }
1122
1194
 
1123
1195
  function useLayoutEffect(create, inputs) {
1196
+ {
1197
+ currentHookNameInDev = 'useLayoutEffect';
1198
+ }
1124
1199
  warning$1(false, 'useLayoutEffect does nothing on the server, because its effect cannot ' + "be encoded into the server renderer's output format. This will lead " + 'to a mismatch between the initial, non-hydrated UI and the intended ' + 'UI. To avoid this, useLayoutEffect should only be used in ' + 'components that render exclusively on the client.');
1125
1200
  }
1126
1201
 
@@ -1157,11 +1232,13 @@ function dispatchAction(componentIdentity, queue, action) {
1157
1232
  }
1158
1233
  }
1159
1234
 
1160
- function noop() {}
1161
- function identity(fn) {
1162
- return fn;
1235
+ function useCallback(callback, deps) {
1236
+ // Callbacks are passed as they are in the server environment.
1237
+ return callback;
1163
1238
  }
1164
1239
 
1240
+ function noop() {}
1241
+
1165
1242
  var currentThreadID = 0;
1166
1243
 
1167
1244
  function setCurrentThreadID(threadID) {
@@ -1176,15 +1253,13 @@ var Dispatcher = {
1176
1253
  useRef: useRef,
1177
1254
  useState: useState,
1178
1255
  useLayoutEffect: useLayoutEffect,
1179
- // Callbacks are passed as they are in the server environment.
1180
- useCallback: identity,
1181
- // useImperativeMethods is not run in the server environment
1182
- useImperativeMethods: noop,
1256
+ useCallback: useCallback,
1257
+ // useImperativeHandle is not run in the server environment
1258
+ useImperativeHandle: noop,
1183
1259
  // Effects are not run in the server environment.
1184
- useEffect: noop
1185
- };
1186
- var DispatcherWithoutHooks = {
1187
- readContext: readContext
1260
+ useEffect: noop,
1261
+ // Debugging effect
1262
+ useDebugValue: noop
1188
1263
  };
1189
1264
 
1190
1265
  var HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';
@@ -3002,11 +3077,7 @@ var ReactDOMServerRenderer = function () {
3002
3077
  var prevThreadID = currentThreadID;
3003
3078
  setCurrentThreadID(this.threadID);
3004
3079
  var prevDispatcher = ReactCurrentDispatcher.current;
3005
- if (enableHooks) {
3006
- ReactCurrentDispatcher.current = Dispatcher;
3007
- } else {
3008
- ReactCurrentDispatcher.current = DispatcherWithoutHooks;
3009
- }
3080
+ ReactCurrentDispatcher.current = Dispatcher;
3010
3081
  try {
3011
3082
  // Markup generated within <Suspense> ends up buffered until we know
3012
3083
  // nothing in that boundary suspended
@@ -3163,7 +3234,25 @@ var ReactDOMServerRenderer = function () {
3163
3234
  case REACT_SUSPENSE_TYPE:
3164
3235
  {
3165
3236
  if (enableSuspenseServerRenderer) {
3166
- var fallbackChildren = toArray(nextChild.props.fallback);
3237
+ var fallback = nextChild.props.fallback;
3238
+ if (fallback === undefined) {
3239
+ // If there is no fallback, then this just behaves as a fragment.
3240
+ var _nextChildren3 = toArray(nextChild.props.children);
3241
+ var _frame3 = {
3242
+ type: null,
3243
+ domNamespace: parentNamespace,
3244
+ children: _nextChildren3,
3245
+ childIndex: 0,
3246
+ context: context,
3247
+ footer: ''
3248
+ };
3249
+ {
3250
+ _frame3.debugElementStack = [];
3251
+ }
3252
+ this.stack.push(_frame3);
3253
+ return '';
3254
+ }
3255
+ var fallbackChildren = toArray(fallback);
3167
3256
  var _nextChildren2 = toArray(nextChild.props.children);
3168
3257
  var _fallbackFrame2 = {
3169
3258
  type: null,
@@ -3181,7 +3270,7 @@ var ReactDOMServerRenderer = function () {
3181
3270
  children: _nextChildren2,
3182
3271
  childIndex: 0,
3183
3272
  context: context,
3184
- footer: ''
3273
+ footer: '<!--/$-->'
3185
3274
  };
3186
3275
  {
3187
3276
  _frame2.debugElementStack = [];
@@ -3189,7 +3278,7 @@ var ReactDOMServerRenderer = function () {
3189
3278
  }
3190
3279
  this.stack.push(_frame2);
3191
3280
  this.suspenseDepth++;
3192
- return '';
3281
+ return '<!--$-->';
3193
3282
  } else {
3194
3283
  invariant(false, 'ReactDOMServer does not yet support Suspense.');
3195
3284
  }
@@ -3203,64 +3292,64 @@ var ReactDOMServerRenderer = function () {
3203
3292
  case REACT_FORWARD_REF_TYPE:
3204
3293
  {
3205
3294
  var element = nextChild;
3206
- var _nextChildren3 = void 0;
3295
+ var _nextChildren4 = void 0;
3207
3296
  var componentIdentity = {};
3208
3297
  prepareToUseHooks(componentIdentity);
3209
- _nextChildren3 = elementType.render(element.props, element.ref);
3210
- _nextChildren3 = finishHooks(elementType.render, element.props, _nextChildren3, element.ref);
3211
- _nextChildren3 = toArray(_nextChildren3);
3212
- var _frame3 = {
3298
+ _nextChildren4 = elementType.render(element.props, element.ref);
3299
+ _nextChildren4 = finishHooks(elementType.render, element.props, _nextChildren4, element.ref);
3300
+ _nextChildren4 = toArray(_nextChildren4);
3301
+ var _frame4 = {
3213
3302
  type: null,
3214
3303
  domNamespace: parentNamespace,
3215
- children: _nextChildren3,
3304
+ children: _nextChildren4,
3216
3305
  childIndex: 0,
3217
3306
  context: context,
3218
3307
  footer: ''
3219
3308
  };
3220
3309
  {
3221
- _frame3.debugElementStack = [];
3310
+ _frame4.debugElementStack = [];
3222
3311
  }
3223
- this.stack.push(_frame3);
3312
+ this.stack.push(_frame4);
3224
3313
  return '';
3225
3314
  }
3226
3315
  case REACT_MEMO_TYPE:
3227
3316
  {
3228
3317
  var _element = nextChild;
3229
- var _nextChildren4 = [React.createElement(elementType.type, _assign({ ref: _element.ref }, _element.props))];
3230
- var _frame4 = {
3318
+ var _nextChildren5 = [React.createElement(elementType.type, _assign({ ref: _element.ref }, _element.props))];
3319
+ var _frame5 = {
3231
3320
  type: null,
3232
3321
  domNamespace: parentNamespace,
3233
- children: _nextChildren4,
3322
+ children: _nextChildren5,
3234
3323
  childIndex: 0,
3235
3324
  context: context,
3236
3325
  footer: ''
3237
3326
  };
3238
3327
  {
3239
- _frame4.debugElementStack = [];
3328
+ _frame5.debugElementStack = [];
3240
3329
  }
3241
- this.stack.push(_frame4);
3330
+ this.stack.push(_frame5);
3242
3331
  return '';
3243
3332
  }
3244
3333
  case REACT_PROVIDER_TYPE:
3245
3334
  {
3246
3335
  var provider = nextChild;
3247
3336
  var nextProps = provider.props;
3248
- var _nextChildren5 = toArray(nextProps.children);
3249
- var _frame5 = {
3337
+ var _nextChildren6 = toArray(nextProps.children);
3338
+ var _frame6 = {
3250
3339
  type: provider,
3251
3340
  domNamespace: parentNamespace,
3252
- children: _nextChildren5,
3341
+ children: _nextChildren6,
3253
3342
  childIndex: 0,
3254
3343
  context: context,
3255
3344
  footer: ''
3256
3345
  };
3257
3346
  {
3258
- _frame5.debugElementStack = [];
3347
+ _frame6.debugElementStack = [];
3259
3348
  }
3260
3349
 
3261
3350
  this.pushProvider(provider);
3262
3351
 
3263
- this.stack.push(_frame5);
3352
+ this.stack.push(_frame6);
3264
3353
  return '';
3265
3354
  }
3266
3355
  case REACT_CONTEXT_TYPE:
@@ -3293,19 +3382,19 @@ var ReactDOMServerRenderer = function () {
3293
3382
  validateContextBounds(reactContext, threadID);
3294
3383
  var nextValue = reactContext[threadID];
3295
3384
 
3296
- var _nextChildren6 = toArray(_nextProps.children(nextValue));
3297
- var _frame6 = {
3385
+ var _nextChildren7 = toArray(_nextProps.children(nextValue));
3386
+ var _frame7 = {
3298
3387
  type: nextChild,
3299
3388
  domNamespace: parentNamespace,
3300
- children: _nextChildren6,
3389
+ children: _nextChildren7,
3301
3390
  childIndex: 0,
3302
3391
  context: context,
3303
3392
  footer: ''
3304
3393
  };
3305
3394
  {
3306
- _frame6.debugElementStack = [];
3395
+ _frame7.debugElementStack = [];
3307
3396
  }
3308
- this.stack.push(_frame6);
3397
+ this.stack.push(_frame7);
3309
3398
  return '';
3310
3399
  }
3311
3400
  case REACT_LAZY_TYPE: