Permalink
Browse files

Sync React 16 from alpha 6 to 12

Reviewed By: spicyj

Differential Revision: D4926070

fbshipit-source-id: c23c79ccd53eb594447d9b47fe3ac6e82499bd42
  • Loading branch information...
bvaughn authored and facebook-github-bot committed May 4, 2017
1 parent cc3d034 commit ef0bd5c71dd65ac4a74a376e5fb155810305ec90
Showing with 1,540 additions and 765 deletions.
  1. +1 −1 Libraries/Components/Touchable/BoundingDimensions.js
  2. +1 −1 Libraries/Components/Touchable/Position.js
  3. +0 −1 Libraries/Image/Image.android.js
  4. +8 −4 Libraries/Performance/Systrace.js
  5. +1 −1 Libraries/Renderer/src/ReactVersion.js
  6. +3 −2 Libraries/Renderer/src/renderers/native/NativeMethodsMixin.js
  7. +4 −2 Libraries/Renderer/src/renderers/native/NativeMethodsMixinUtils.js
  8. +2 −1 Libraries/Renderer/src/renderers/native/ReactNativeAttributePayload.js
  9. +1 −0 Libraries/Renderer/src/renderers/native/ReactNativeBaseComponent.js
  10. +2 −3 Libraries/Renderer/src/renderers/native/ReactNativeBridgeEventPlugin.js
  11. +8 −3 Libraries/Renderer/src/renderers/native/ReactNativeFiber.js
  12. +1 −4 Libraries/Renderer/src/renderers/native/ReactNativeFiberHostComponent.js
  13. +3 −0 Libraries/Renderer/src/renderers/native/__tests__/ReactNativeEvents-test.js
  14. +29 −1 Libraries/Renderer/src/renderers/native/__tests__/ReactNativeMount-test.js
  15. +7 −0 Libraries/Renderer/src/renderers/native/__tests__/__snapshots__/ReactNativeEvents-test.js.snap
  16. +51 −0 Libraries/Renderer/src/renderers/native/__tests__/__snapshots__/ReactNativeMount-test.js.snap
  17. +1 −1 Libraries/Renderer/src/renderers/native/findNodeHandle.js
  18. +12 −13 Libraries/Renderer/src/renderers/native/takeSnapshot.js
  19. +6 −0 Libraries/Renderer/src/renderers/noop/ReactNoop.js
  20. +170 −0 Libraries/Renderer/src/renderers/shared/ReactDOMFrameScheduling.js
  21. +24 −24 Libraries/Renderer/src/renderers/shared/ReactDebugTool.js
  22. +28 −0 Libraries/Renderer/src/renderers/shared/ReactGlobalSharedState.js
  23. +8 −7 Libraries/Renderer/src/renderers/shared/ReactPerf.js
  24. +55 −0 Libraries/Renderer/src/renderers/shared/__tests__/ReactDOMFrameScheduling-test.js
  25. +155 −67 Libraries/Renderer/src/renderers/shared/fiber/ReactChildFiber.js
  26. +2 −1 Libraries/Renderer/src/renderers/shared/fiber/ReactDebugFiberPerf.js
  27. +67 −26 Libraries/Renderer/src/renderers/shared/fiber/ReactFiber.js
  28. +14 −24 Libraries/Renderer/src/renderers/shared/fiber/ReactFiberBeginWork.js
  29. +61 −27 Libraries/Renderer/src/renderers/shared/fiber/ReactFiberClassComponent.js
  30. +7 −7 Libraries/Renderer/src/renderers/shared/fiber/ReactFiberCommitWork.js
  31. +2 −8 Libraries/Renderer/src/renderers/shared/fiber/ReactFiberCompleteWork.js
  32. +22 −22 Libraries/Renderer/src/renderers/shared/fiber/ReactFiberContext.js
  33. +8 −9 Libraries/Renderer/src/renderers/shared/fiber/ReactFiberErrorLogger.js
  34. +28 −39 Libraries/Renderer/src/renderers/shared/fiber/ReactFiberHostContext.js
  35. +19 −12 Libraries/Renderer/src/renderers/shared/fiber/ReactFiberReconciler.js
  36. +40 −22 Libraries/Renderer/src/renderers/shared/fiber/ReactFiberScheduler.js
  37. +2 −5 Libraries/Renderer/src/renderers/shared/fiber/ReactFiberTreeReflection.js
  38. +3 −4 Libraries/Renderer/src/renderers/shared/fiber/ReactFiberUpdateQueue.js
  39. +20 −0 Libraries/Renderer/src/renderers/shared/fiber/ReactTypeOfInternalContext.js
  40. +9 −9 Libraries/Renderer/src/renderers/shared/fiber/ReactTypeOfSideEffect.js
  41. +16 −10 Libraries/Renderer/src/renderers/shared/fiber/__tests__/ReactCoroutine-test.js
  42. +62 −0 Libraries/Renderer/src/renderers/shared/fiber/__tests__/ReactFiberHostContext-test.js
  43. +67 −25 Libraries/Renderer/src/renderers/shared/fiber/__tests__/ReactIncremental-test.js
  44. +3 −1 Libraries/Renderer/src/renderers/shared/fiber/__tests__/ReactIncrementalErrorHandling-test.js
  45. +14 −12 Libraries/Renderer/src/renderers/shared/fiber/__tests__/ReactIncrementalPerf-test.js
  46. +30 −22 Libraries/Renderer/src/renderers/shared/fiber/__tests__/ReactIncrementalReflection-test.js
  47. +5 −2 Libraries/Renderer/src/renderers/shared/fiber/__tests__/ReactIncrementalSideEffects-test.js
  48. +24 −24 Libraries/Renderer/src/renderers/shared/fiber/__tests__/ReactIncrementalUpdates-test.js
  49. +4 −4 Libraries/Renderer/src/renderers/shared/fiber/__tests__/ReactTopLevelFragment-test.js
  50. +8 −4 Libraries/Renderer/src/renderers/shared/fiber/isomorphic/ReactCoroutine.js
  51. +6 −5 Libraries/Renderer/src/renderers/shared/fiber/isomorphic/ReactPortal.js
  52. +10 −12 Libraries/Renderer/src/renderers/shared/hooks/ReactHostOperationHistoryHook.js
  53. +103 −0 Libraries/Renderer/src/renderers/shared/shared/event/BrowserEventConstants.js
  54. +0 −99 Libraries/Renderer/src/renderers/shared/shared/event/EventConstants.js
  55. +6 −3 Libraries/Renderer/src/renderers/shared/shared/event/EventPluginHub.js
  56. +2 −3 Libraries/Renderer/src/renderers/shared/shared/event/EventPluginRegistry.js
  57. +4 −2 Libraries/Renderer/src/renderers/shared/shared/event/EventPluginUtils.js
  58. +3 −4 Libraries/Renderer/src/renderers/shared/shared/event/EventPropagators.js
  59. +8 −10 Libraries/Renderer/src/renderers/shared/shared/event/ReactSyntheticEventType.js
  60. +17 −10 Libraries/Renderer/src/renderers/shared/shared/event/eventPlugins/ResponderEventPlugin.js
  61. +3 −8 Libraries/Renderer/src/renderers/shared/shared/event/eventPlugins/ResponderTouchHistoryStore.js
  62. +4 −6 ...es/Renderer/src/renderers/shared/shared/event/eventPlugins/__tests__/ResponderEventPlugin-test.js
  63. +101 −0 Libraries/Renderer/src/renderers/shared/shared/event/getVendorPrefixedEventName.js
  64. +4 −2 Libraries/Renderer/src/renderers/shared/shared/shouldUpdateReactComponent.js
  65. +11 −7 Libraries/Renderer/src/renderers/shared/stack/reconciler/ReactChildReconciler.js
  66. +4 −2 Libraries/Renderer/src/renderers/shared/stack/reconciler/ReactComponentEnvironment.js
  67. +40 −25 Libraries/Renderer/src/renderers/shared/stack/reconciler/ReactCompositeComponent.js
  68. +7 −4 Libraries/Renderer/src/renderers/shared/stack/reconciler/ReactMultiChild.js
  69. +7 −6 Libraries/Renderer/src/renderers/shared/stack/reconciler/ReactRef.js
  70. +3 −2 Libraries/Renderer/src/renderers/shared/stack/reconciler/ReactUpdateQueue.js
  71. +10 −8 Libraries/Renderer/src/renderers/shared/stack/reconciler/Transaction.js
  72. +10 −8 ...src/{shared/utils/flattenChildren.js → renderers/shared/stack/reconciler/flattenStackChildren.js}
  73. +6 −3 Libraries/Renderer/src/renderers/shared/stack/reconciler/instantiateReactComponent.js
  74. +20 −28 ...shared/utils/traverseAllChildren.js → renderers/shared/stack/reconciler/traverseStackChildren.js}
  75. +9 −9 Libraries/Renderer/src/renderers/shared/utils/ReactErrorUtils.js
  76. +1 −0 Libraries/Renderer/src/renderers/shared/utils/ReactFeatureFlags.js
  77. +4 −3 Libraries/Renderer/src/renderers/shared/utils/adler32.js
  78. +4 −2 Libraries/Renderer/src/shared/ReactFiberComponentTreeHook.js
  79. +0 −26 Libraries/Renderer/src/shared/types/checkReactTypeSpec.js
  80. +1 −1 Libraries/Renderer/src/shared/utils/PooledClass.js
  81. +2 −3 Libraries/Renderer/src/shared/utils/ReactElementSymbol.js
  82. +1 −1 Libraries/Renderer/src/shared/utils/getComponentName.js
  83. +2 −1 Libraries/Renderer/src/shared/utils/getIteratorFn.js
  84. +4 −2 Libraries/Renderer/src/shared/utils/reactProdInvariant.js
  85. +1 −1 Libraries/react-native/React.js
  86. +4 −4 package.json
@@ -11,7 +11,7 @@
'use strict';
var PooledClass = require('react/lib/PooledClass');
var PooledClass = require('PooledClass');
var twoArgumentPooler = PooledClass.twoArgumentPooler;
@@ -11,7 +11,7 @@
'use strict';
var PooledClass = require('react/lib/PooledClass');
var PooledClass = require('PooledClass');
var twoArgumentPooler = PooledClass.twoArgumentPooler;
@@ -15,7 +15,6 @@ var ImageResizeMode = require('ImageResizeMode');
var ImageStylePropTypes = require('ImageStylePropTypes');
var NativeMethodsMixin = require('NativeMethodsMixin');
var NativeModules = require('NativeModules');
var PropTypes = require('react/lib/ReactPropTypes');
var React = require('React');
var PropTypes = require('prop-types');
var ReactNativeViewAttributes = require('ReactNativeViewAttributes');
@@ -32,28 +32,32 @@ let _asyncCookie = 0;
const ReactSystraceDevtool = __DEV__ ? {
onBeforeMountComponent(debugID) {
const displayName = require('react/lib/ReactComponentTreeHook').getDisplayName(debugID);
const ReactComponentTreeHook = require('ReactGlobalSharedState').ReactComponentTreeHook;
const displayName = ReactComponentTreeHook.getDisplayName(debugID);
Systrace.beginEvent(`ReactReconciler.mountComponent(${displayName})`);
},
onMountComponent(debugID) {
Systrace.endEvent();
},
onBeforeUpdateComponent(debugID) {
const displayName = require('react/lib/ReactComponentTreeHook').getDisplayName(debugID);
const ReactComponentTreeHook = require('ReactGlobalSharedState').ReactComponentTreeHook;
const displayName = ReactComponentTreeHook.getDisplayName(debugID);
Systrace.beginEvent(`ReactReconciler.updateComponent(${displayName})`);
},
onUpdateComponent(debugID) {
Systrace.endEvent();
},
onBeforeUnmountComponent(debugID) {
const displayName = require('react/lib/ReactComponentTreeHook').getDisplayName(debugID);
const ReactComponentTreeHook = require('ReactGlobalSharedState').ReactComponentTreeHook;
const displayName = ReactComponentTreeHook.getDisplayName(debugID);
Systrace.beginEvent(`ReactReconciler.unmountComponent(${displayName})`);
},
onUnmountComponent(debugID) {
Systrace.endEvent();
},
onBeginLifeCycleTimer(debugID, timerType) {
const displayName = require('react/lib/ReactComponentTreeHook').getDisplayName(debugID);
const ReactComponentTreeHook = require('ReactGlobalSharedState').ReactComponentTreeHook;
const displayName = ReactComponentTreeHook.getDisplayName(debugID);
Systrace.beginEvent(`${displayName}.${timerType}()`);
},
onEndLifeCycleTimer(debugID, timerType) {
@@ -11,4 +11,4 @@
'use strict';
module.exports = '16.0.0-alpha.6';
module.exports = '16.0.0-alpha.12';
@@ -99,7 +99,7 @@ var NativeMethodsMixin = {
},
/**
* Like [`measure()`](#measure), but measures the view relative to an ancestor,
* Like [`measure()`](#measure), but measures the view relative an ancestor,
* specified as `relativeToNativeNode`. This means that the returned x, y
* are relative to the origin x, y of the ancestor view.
*
@@ -176,7 +176,8 @@ function setNativePropsFiber(componentOrHandle: any, nativeProps: Object) {
return;
}
const viewConfig: ReactNativeBaseComponentViewConfig = maybeInstance.viewConfig;
const viewConfig: ReactNativeBaseComponentViewConfig =
maybeInstance.viewConfig;
if (__DEV__) {
warnForStyleProps(nativeProps, viewConfig.validAttributes);
@@ -71,12 +71,14 @@ function throwOnStylesProp(component: any, props: any) {
if (props.styles !== undefined) {
var owner = component._owner || null;
var name = component.constructor.displayName;
var msg = '`styles` is not a supported property of `' +
var msg =
'`styles` is not a supported property of `' +
name +
'`, did ' +
'you mean `style` (singular)?';
if (owner && owner.constructor && owner.constructor.displayName) {
msg += '\n\nCheck the `' +
msg +=
'\n\nCheck the `' +
owner.constructor.displayName +
'` parent ' +
' component.';
@@ -377,7 +377,8 @@ function diffProperties(
typeof attributeConfig.process === 'function'
) {
// case: CustomAttributeConfiguration
var shouldUpdate = prevProp === undefined ||
var shouldUpdate =
prevProp === undefined ||
(typeof attributeConfig.diff === 'function'
? attributeConfig.diff(prevProp, nextProp)
: defaultDiffer(prevProp, nextProp));
@@ -9,6 +9,7 @@
* @providesModule ReactNativeBaseComponent
* @flow
*/
'use strict';
var NativeMethodsMixin = require('NativeMethodsMixin');
@@ -23,9 +23,8 @@ var customDirectEventTypes = UIManager.customDirectEventTypes;
var allTypesByEventName = {};
for (var bubblingTypeName in customBubblingEventTypes) {
allTypesByEventName[bubblingTypeName] = customBubblingEventTypes[
bubblingTypeName
];
allTypesByEventName[bubblingTypeName] =
customBubblingEventTypes[bubblingTypeName];
}
for (var directTypeName in customDirectEventTypes) {
@@ -23,6 +23,7 @@ const ReactNativeInjection = require('ReactNativeInjection');
const ReactNativeTagHandles = require('ReactNativeTagHandles');
const ReactNativeViewConfigRegistry = require('ReactNativeViewConfigRegistry');
const ReactPortal = require('ReactPortal');
const ReactVersion = require('ReactVersion');
const UIManager = require('UIManager');
const deepFreezeAndThrowOnMutationInDev = require('deepFreezeAndThrowOnMutationInDev');
@@ -239,9 +240,9 @@ const NativeRenderer = ReactFiberReconciler({
// Either way we need to pass a copy of the Array to prevent it from being frozen.
const nativeTags = parentInstance._children.map(
child =>
typeof child === 'number'
(typeof child === 'number'
? child // Leaf node (eg text)
: child._nativeTag,
: child._nativeTag),
);
UIManager.setChildren(
@@ -396,7 +397,8 @@ ReactGenericBatching.injection.injectFiberBatchedUpdates(
const roots = new Map();
findNodeHandle.injection.injectFindNode((fiber: Fiber) =>
NativeRenderer.findHostInstance(fiber));
NativeRenderer.findHostInstance(fiber),
);
findNodeHandle.injection.injectFindRootNodeID(instance => instance);
// Intercept lifecycle errors and ensure they are shown with the correct stack
@@ -463,6 +465,9 @@ if (typeof injectInternals === 'function') {
injectInternals({
findFiberByHostInstance: ReactNativeComponentTree.getClosestInstanceFromNode,
findHostInstanceByFiber: NativeRenderer.findHostInstance,
// This is an enum because we may add more (e.g. profiler build)
bundleType: __DEV__ ? 1 : 0,
version: ReactVersion,
});
}
@@ -17,10 +17,7 @@ var ReactNativeAttributePayload = require('ReactNativeAttributePayload');
var TextInputState = require('TextInputState');
var UIManager = require('UIManager');
var {
mountSafeCallback,
warnForStyleProps,
} = require('NativeMethodsMixinUtils');
var {mountSafeCallback, warnForStyleProps} = require('NativeMethodsMixinUtils');
import type {
MeasureInWindowOnSuccessCallback,
@@ -11,6 +11,7 @@
'use strict';
var PropTypes;
var RCTEventEmitter;
var React;
var ReactNative;
@@ -21,6 +22,7 @@ var createReactNativeComponentClass;
beforeEach(() => {
jest.resetModules();
PropTypes = require('prop-types');
RCTEventEmitter = require('RCTEventEmitter');
React = require('react');
ReactNative = require('ReactNative');
@@ -56,6 +58,7 @@ it('handles events', () => {
1,
);
expect(UIManager.__dumpHierarchyForJestTestsOnly()).toMatchSnapshot();
expect(UIManager.createView.mock.calls.length).toBe(2);
// Don't depend on the order of createView() calls.
@@ -69,7 +69,7 @@ describe('ReactNative', () => {
var a;
var b;
var c = ReactNative.render(
<View foo="foo" ref={v => a = v} />,
<View foo="foo" ref={v => (a = v)} />,
11,
function() {
b = this;
@@ -80,4 +80,32 @@ describe('ReactNative', () => {
expect(a).toBe(b);
expect(a).toBe(c);
});
it('renders and reorders children', () => {
var View = createReactNativeComponentClass({
validAttributes: {title: true},
uiViewClassName: 'View',
});
class Component extends React.Component {
render() {
var chars = this.props.chars.split('');
return (
<View>
{chars.map(text => <View key={text} title={text} />)}
</View>
);
}
}
// Mini multi-child stress test: lots of reorders, some adds, some removes.
var before = 'abcdefghijklmnopqrst';
var after = 'mxhpgwfralkeoivcstzy';
ReactNative.render(<Component chars={before} />, 11);
expect(UIManager.__dumpHierarchyForJestTestsOnly()).toMatchSnapshot();
ReactNative.render(<Component chars={after} />, 11);
expect(UIManager.__dumpHierarchyForJestTestsOnly()).toMatchSnapshot();
});
});
@@ -0,0 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`handles events 1`] = `
"<native root> {}
View {\\"foo\\":\\"outer\\"}
View {\\"foo\\":\\"inner\\"}"
`;
@@ -0,0 +1,51 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`ReactNative renders and reorders children 1`] = `
"<native root> {}
View null
View {\\"title\\":\\"a\\"}
View {\\"title\\":\\"b\\"}
View {\\"title\\":\\"c\\"}
View {\\"title\\":\\"d\\"}
View {\\"title\\":\\"e\\"}
View {\\"title\\":\\"f\\"}
View {\\"title\\":\\"g\\"}
View {\\"title\\":\\"h\\"}
View {\\"title\\":\\"i\\"}
View {\\"title\\":\\"j\\"}
View {\\"title\\":\\"k\\"}
View {\\"title\\":\\"l\\"}
View {\\"title\\":\\"m\\"}
View {\\"title\\":\\"n\\"}
View {\\"title\\":\\"o\\"}
View {\\"title\\":\\"p\\"}
View {\\"title\\":\\"q\\"}
View {\\"title\\":\\"r\\"}
View {\\"title\\":\\"s\\"}
View {\\"title\\":\\"t\\"}"
`;
exports[`ReactNative renders and reorders children 2`] = `
"<native root> {}
View null
View {\\"title\\":\\"m\\"}
View {\\"title\\":\\"x\\"}
View {\\"title\\":\\"h\\"}
View {\\"title\\":\\"p\\"}
View {\\"title\\":\\"g\\"}
View {\\"title\\":\\"w\\"}
View {\\"title\\":\\"f\\"}
View {\\"title\\":\\"r\\"}
View {\\"title\\":\\"a\\"}
View {\\"title\\":\\"l\\"}
View {\\"title\\":\\"k\\"}
View {\\"title\\":\\"e\\"}
View {\\"title\\":\\"o\\"}
View {\\"title\\":\\"i\\"}
View {\\"title\\":\\"v\\"}
View {\\"title\\":\\"c\\"}
View {\\"title\\":\\"s\\"}
View {\\"title\\":\\"t\\"}
View {\\"title\\":\\"z\\"}
View {\\"title\\":\\"y\\"}"
`;
@@ -12,8 +12,8 @@
'use strict';
var ReactCurrentOwner = require('react/lib/ReactCurrentOwner');
var ReactInstanceMap = require('ReactInstanceMap');
var {ReactCurrentOwner} = require('ReactGlobalSharedState');
var invariant = require('fbjs/lib/invariant');
var warning = require('fbjs/lib/warning');
@@ -33,23 +33,22 @@ import type {Element} from 'React';
* Returns a Promise.
* @platform ios
*/
module.exports = async function takeSnapshot(
view ?: 'window' | Element<any> | number,
options ?: {
width ?: number,
height ?: number,
format ?: 'png' | 'jpeg',
quality ?: number,
function takeSnapshot(
view?: 'window' | Element<any> | number,
options?: {
width?: number,
height?: number,
format?: 'png' | 'jpeg',
quality?: number,
},
) {
if (
typeof view !== 'number' &&
view !== 'window'
) {
): Promise<any> {
if (typeof view !== 'number' && view !== 'window') {
view = ReactNative.findNodeHandle(view) || 'window';
}
// Call the hidden '__takeSnapshot' method; the main one throws an error to
// prevent accidental backwards-incompatible usage.
return UIManager.__takeSnapshot(view, options);
};
}
module.exports = takeSnapshot;
@@ -22,6 +22,7 @@
import type { Fiber } from 'ReactFiber';
import type { UpdateQueue } from 'ReactFiberUpdateQueue';
var ReactFiberInstrumentation = require('ReactFiberInstrumentation');
var ReactFiberReconciler = require('ReactFiberReconciler');
var ReactInstanceMap = require('ReactInstanceMap');
var {
@@ -380,6 +381,11 @@ var ReactNoop = {
}
},
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: {
// Private. Used only by fixtures/fiber-debugger.
// (To be fair, it's the only place where `react-noop-renderer` package is used at all.)
ReactFiberInstrumentation,
},
};
module.exports = ReactNoop;
Oops, something went wrong.

0 comments on commit ef0bd5c

Please sign in to comment.