diff --git a/Libraries/Components/Touchable/BoundingDimensions.js b/Libraries/Components/Touchable/BoundingDimensions.js index 7d654c11de71a7..a5877717b6b651 100644 --- a/Libraries/Components/Touchable/BoundingDimensions.js +++ b/Libraries/Components/Touchable/BoundingDimensions.js @@ -11,7 +11,7 @@ 'use strict'; -var PooledClass = require('react/lib/PooledClass'); +var PooledClass = require('PooledClass'); var twoArgumentPooler = PooledClass.twoArgumentPooler; diff --git a/Libraries/Components/Touchable/Position.js b/Libraries/Components/Touchable/Position.js index e85f8dd35d5f0e..77dd3ad11b81e9 100644 --- a/Libraries/Components/Touchable/Position.js +++ b/Libraries/Components/Touchable/Position.js @@ -11,7 +11,7 @@ 'use strict'; -var PooledClass = require('react/lib/PooledClass'); +var PooledClass = require('PooledClass'); var twoArgumentPooler = PooledClass.twoArgumentPooler; diff --git a/Libraries/Image/Image.android.js b/Libraries/Image/Image.android.js index 4820d75702eb85..9d2cce1f2bf141 100644 --- a/Libraries/Image/Image.android.js +++ b/Libraries/Image/Image.android.js @@ -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 ReactNativeViewAttributes = require('ReactNativeViewAttributes'); var Set = require('Set'); diff --git a/Libraries/Performance/Systrace.js b/Libraries/Performance/Systrace.js index 7a21d94936b2b5..d1d9e2f76cac99 100644 --- a/Libraries/Performance/Systrace.js +++ b/Libraries/Performance/Systrace.js @@ -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) { diff --git a/Libraries/Renderer/src/ReactVersion.js b/Libraries/Renderer/src/ReactVersion.js index 6bf2d3b1bba84c..d6ec94ed53dee3 100644 --- a/Libraries/Renderer/src/ReactVersion.js +++ b/Libraries/Renderer/src/ReactVersion.js @@ -11,4 +11,4 @@ 'use strict'; -module.exports = '16.0.0-alpha.6'; +module.exports = '16.0.0-alpha.8'; diff --git a/Libraries/Renderer/src/renderers/native/ReactNativeFiber.js b/Libraries/Renderer/src/renderers/native/ReactNativeFiber.js index b770c7ae52fda8..dd4b7a215d4a7f 100644 --- a/Libraries/Renderer/src/renderers/native/ReactNativeFiber.js +++ b/Libraries/Renderer/src/renderers/native/ReactNativeFiber.js @@ -29,7 +29,6 @@ const deepFreezeAndThrowOnMutationInDev = require('deepFreezeAndThrowOnMutationI const emptyObject = require('fbjs/lib/emptyObject'); const findNodeHandle = require('findNodeHandle'); const invariant = require('fbjs/lib/invariant'); -const takeSnapshot = require('takeSnapshot'); const {injectInternals} = require('ReactFiberDevToolsHook'); @@ -72,10 +71,7 @@ const NativeRenderer = ReactFiberReconciler({ parentInstance: Instance | Container, child: Instance | TextInstance, ): void { - - const childTag = typeof child === 'number' - ? child - : child._nativeTag; + const childTag = typeof child === 'number' ? child : child._nativeTag; if (typeof parentInstance === 'number') { // Root container @@ -287,9 +283,7 @@ const NativeRenderer = ReactFiberReconciler({ } else { children.splice(beforeChildIndex, 0, child); - const childTag = typeof child === 'number' - ? child - : child._nativeTag; + const childTag = typeof child === 'number' ? child : child._nativeTag; UIManager.manageChildren( (parentInstance: any)._nativeTag, // containerID @@ -388,7 +382,6 @@ findNodeHandle.injection.injectFindNode((fiber: Fiber) => NativeRenderer.findHostInstance(fiber)); findNodeHandle.injection.injectFindRootNodeID(instance => instance); - // Intercept lifecycle errors and ensure they are shown with the correct stack // trace within the native redbox component. ReactFiberErrorLogger.injection.injectDialog( @@ -421,8 +414,6 @@ const ReactNative = { return NativeRenderer.getPublicRootInstance(root); }, - takeSnapshot, - unmountComponentAtNode(containerTag: number) { const root = roots.get(containerTag); if (root) { diff --git a/Libraries/Renderer/src/renderers/native/ReactNativeStack.js b/Libraries/Renderer/src/renderers/native/ReactNativeStack.js index 0d1f323f0237e8..a9fa118cf27b6a 100644 --- a/Libraries/Renderer/src/renderers/native/ReactNativeStack.js +++ b/Libraries/Renderer/src/renderers/native/ReactNativeStack.js @@ -18,7 +18,6 @@ var ReactNativeStackInjection = require('ReactNativeStackInjection'); var ReactUpdates = require('ReactUpdates'); var findNodeHandle = require('findNodeHandle'); -var takeSnapshot = require('takeSnapshot'); ReactNativeInjection.inject(); ReactNativeStackInjection.inject(); @@ -47,8 +46,6 @@ var ReactNative = { render: render, - takeSnapshot, - unmountComponentAtNode: ReactNativeMount.unmountComponentAtNode, /* eslint-disable camelcase */ diff --git a/Libraries/Renderer/src/renderers/native/findNodeHandle.js b/Libraries/Renderer/src/renderers/native/findNodeHandle.js index 68ec7e503da84b..10008836ff70cc 100644 --- a/Libraries/Renderer/src/renderers/native/findNodeHandle.js +++ b/Libraries/Renderer/src/renderers/native/findNodeHandle.js @@ -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'); diff --git a/Libraries/Renderer/src/renderers/native/takeSnapshot.js b/Libraries/Renderer/src/renderers/native/takeSnapshot.js index f0f39d3f20ba79..98608c83e5ff30 100644 --- a/Libraries/Renderer/src/renderers/native/takeSnapshot.js +++ b/Libraries/Renderer/src/renderers/native/takeSnapshot.js @@ -33,23 +33,22 @@ import type {Element} from 'React'; * Returns a Promise. * @platform ios */ -module.exports = async function takeSnapshot( - view ?: 'window' | Element | number, - options ?: { - width ?: number, - height ?: number, - format ?: 'png' | 'jpeg', - quality ?: number, +function takeSnapshot( + view?: 'window' | Element | number, + options?: { + width?: number, + height?: number, + format?: 'png' | 'jpeg', + quality?: number, }, -) { - if ( - typeof view !== 'number' && - view !== 'window' - ) { +): Promise { + 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; diff --git a/Libraries/Renderer/src/renderers/noop/ReactNoop.js b/Libraries/Renderer/src/renderers/noop/ReactNoop.js index b0f990548b05b0..331eed4928a3b7 100644 --- a/Libraries/Renderer/src/renderers/noop/ReactNoop.js +++ b/Libraries/Renderer/src/renderers/noop/ReactNoop.js @@ -19,9 +19,10 @@ 'use strict'; -import type { Fiber } from 'ReactFiber'; -import type { UpdateQueue } from 'ReactFiberUpdateQueue'; +import type {Fiber} from 'ReactFiber'; +import type {UpdateQueue} from 'ReactFiberUpdateQueue'; +var ReactFiberInstrumentation = require('ReactFiberInstrumentation'); var ReactFiberReconciler = require('ReactFiberReconciler'); var ReactInstanceMap = require('ReactInstanceMap'); var { @@ -34,17 +35,21 @@ const UPDATE_SIGNAL = {}; var scheduledAnimationCallback = null; var scheduledDeferredCallback = null; -type Container = { rootID: string, children: Array }; -type Props = { prop: any }; -type Instance = {| type: string, id: number, children: Array, prop: any |}; -type TextInstance = {| text: string, id: number |}; +type Container = {rootID: string, children: Array}; +type Props = {prop: any, hidden?: boolean}; +type Instance = {| + type: string, + id: number, + children: Array, + prop: any, +|}; +type TextInstance = {|text: string, id: number|}; var instanceCounter = 0; var failInBeginPhase = false; var NoopRenderer = ReactFiberReconciler({ - getRootHostContext() { if (failInBeginPhase) { throw new Error('Error in host config.'); @@ -60,7 +65,7 @@ var NoopRenderer = ReactFiberReconciler({ return instance; }, - createInstance(type : string, props : Props) : Instance { + createInstance(type: string, props: Props): Instance { const inst = { id: instanceCounter++, type: type, @@ -68,56 +73,83 @@ var NoopRenderer = ReactFiberReconciler({ prop: props.prop, }; // Hide from unit tests - Object.defineProperty(inst, 'id', { value: inst.id, enumerable: false }); + Object.defineProperty(inst, 'id', {value: inst.id, enumerable: false}); return inst; }, - appendInitialChild(parentInstance : Instance, child : Instance | TextInstance) : void { + appendInitialChild( + parentInstance: Instance, + child: Instance | TextInstance, + ): void { parentInstance.children.push(child); }, - finalizeInitialChildren(domElement : Instance, type : string, props : Props) : boolean { + finalizeInitialChildren( + domElement: Instance, + type: string, + props: Props, + ): boolean { return false; }, - prepareUpdate(instance : Instance, type : string, oldProps : Props, newProps : Props) : null | {} { + prepareUpdate( + instance: Instance, + type: string, + oldProps: Props, + newProps: Props, + ): null | {} { return UPDATE_SIGNAL; }, - commitMount(instance : Instance, type : string, newProps : Props) : void { + commitMount(instance: Instance, type: string, newProps: Props): void { // Noop }, - commitUpdate(instance : Instance, updatePayload : Object, type : string, oldProps : Props, newProps : Props) : void { + commitUpdate( + instance: Instance, + updatePayload: Object, + type: string, + oldProps: Props, + newProps: Props, + ): void { instance.prop = newProps.prop; }, - shouldSetTextContent(props : Props) : boolean { - return ( - typeof props.children === 'string' || - typeof props.children === 'number' - ); + shouldSetTextContent(props: Props): boolean { + return typeof props.children === 'string' || + typeof props.children === 'number'; }, - resetTextContent(instance : Instance) : void {}, + resetTextContent(instance: Instance): void {}, + + shouldDeprioritizeSubtree(type: string, props: Props): boolean { + return !!props.hidden; + }, createTextInstance( - text : string, - rootContainerInstance : Container, - hostContext : Object, - internalInstanceHandle : Object - ) : TextInstance { - var inst = { text : text, id: instanceCounter++ }; + text: string, + rootContainerInstance: Container, + hostContext: Object, + internalInstanceHandle: Object, + ): TextInstance { + var inst = {text: text, id: instanceCounter++}; // Hide from unit tests - Object.defineProperty(inst, 'id', { value: inst.id, enumerable: false }); + Object.defineProperty(inst, 'id', {value: inst.id, enumerable: false}); return inst; }, - commitTextUpdate(textInstance : TextInstance, oldText : string, newText : string) : void { + commitTextUpdate( + textInstance: TextInstance, + oldText: string, + newText: string, + ): void { textInstance.text = newText; }, - appendChild(parentInstance : Instance | Container, child : Instance | TextInstance) : void { + appendChild( + parentInstance: Instance | Container, + child: Instance | TextInstance, + ): void { const index = parentInstance.children.indexOf(child); if (index !== -1) { parentInstance.children.splice(index, 1); @@ -126,10 +158,10 @@ var NoopRenderer = ReactFiberReconciler({ }, insertBefore( - parentInstance : Instance | Container, - child : Instance | TextInstance, - beforeChild : Instance | TextInstance - ) : void { + parentInstance: Instance | Container, + child: Instance | TextInstance, + beforeChild: Instance | TextInstance, + ): void { const index = parentInstance.children.indexOf(child); if (index !== -1) { parentInstance.children.splice(index, 1); @@ -141,7 +173,10 @@ var NoopRenderer = ReactFiberReconciler({ parentInstance.children.splice(beforeIndex, 0, child); }, - removeChild(parentInstance : Instance | Container, child : Instance | TextInstance) : void { + removeChild( + parentInstance: Instance | Container, + child: Instance | TextInstance, + ): void { const index = parentInstance.children.indexOf(child); if (index === -1) { throw new Error('This child does not exist.'); @@ -149,15 +184,11 @@ var NoopRenderer = ReactFiberReconciler({ parentInstance.children.splice(index, 1); }, - shouldDeprioritizeSubtree(type: string, props: Props): boolean { - return false; - }, - scheduleAnimationCallback(callback) { if (scheduledAnimationCallback) { throw new Error( 'Scheduling an animation callback twice is excessive. ' + - 'Instead, keep track of whether the callback has already been scheduled.' + 'Instead, keep track of whether the callback has already been scheduled.', ); } scheduledAnimationCallback = callback; @@ -167,18 +198,15 @@ var NoopRenderer = ReactFiberReconciler({ if (scheduledDeferredCallback) { throw new Error( 'Scheduling deferred callback twice is excessive. ' + - 'Instead, keep track of whether the callback has already been scheduled.' + 'Instead, keep track of whether the callback has already been scheduled.', ); } scheduledDeferredCallback = callback; }, - prepareForCommit() : void { - }, - - resetAfterCommit() : void { - }, + prepareForCommit(): void {}, + resetAfterCommit(): void {}, }); var rootContainers = new Map(); @@ -186,8 +214,7 @@ var roots = new Map(); var DEFAULT_ROOT_ID = ''; var ReactNoop = { - - getChildren(rootID : string = DEFAULT_ROOT_ID) { + getChildren(rootID: string = DEFAULT_ROOT_ID) { const container = rootContainers.get(rootID); if (container) { return container.children; @@ -197,14 +224,18 @@ var ReactNoop = { }, // Shortcut for testing a single root - render(element : ReactElement, callback: ?Function) { + render(element: ReactElement, callback: ?Function) { ReactNoop.renderToRootWithID(element, DEFAULT_ROOT_ID, callback); }, - renderToRootWithID(element : ReactElement, rootID : string, callback : ?Function) { + renderToRootWithID( + element: ReactElement, + rootID: string, + callback: ?Function, + ) { let root = roots.get(rootID); if (!root) { - const container = { rootID: rootID, children: [] }; + const container = {rootID: rootID, children: []}; rootContainers.set(rootID, container); root = NoopRenderer.createContainer(container); roots.set(rootID, root); @@ -212,7 +243,7 @@ var ReactNoop = { NoopRenderer.updateContainer(element, root, null, callback); }, - unmountRootWithID(rootID : string) { + unmountRootWithID(rootID: string) { const root = roots.get(rootID); if (root) { NoopRenderer.updateContainer(null, root, null, () => { @@ -222,12 +253,14 @@ var ReactNoop = { } }, - findInstance(componentOrElement : Element | ?ReactComponent) : null | Instance | TextInstance { + findInstance( + componentOrElement: Element | ?ReactComponent, + ): null | Instance | TextInstance { if (componentOrElement == null) { return null; } // Unsound duck typing. - const component = (componentOrElement : any); + const component = (componentOrElement: any); if (typeof component.id === 'number') { return component; } @@ -244,7 +277,7 @@ var ReactNoop = { cb(); }, - flushDeferredPri(timeout : number = Infinity) { + flushDeferredPri(timeout: number = Infinity) { var cb = scheduledDeferredCallback; if (cb === null) { return; @@ -279,7 +312,7 @@ var ReactNoop = { syncUpdates: NoopRenderer.syncUpdates, // Logs the current state of the tree. - dumpTree(rootID : string = DEFAULT_ROOT_ID) { + dumpTree(rootID: string = DEFAULT_ROOT_ID) { const root = roots.get(rootID); const rootContainer = rootContainers.get(rootID); if (!root || !rootContainer) { @@ -306,15 +339,13 @@ var ReactNoop = { } } } - function logContainer(container : Container, depth) { + function logContainer(container: Container, depth) { log(' '.repeat(depth) + '- [root#' + container.rootID + ']'); logHostInstances(container.children, depth + 1); } - function logUpdateQueue(updateQueue : UpdateQueue, depth) { - log( - ' '.repeat(depth + 1) + 'QUEUED UPDATES' - ); + function logUpdateQueue(updateQueue: UpdateQueue, depth) { + log(' '.repeat(depth + 1) + 'QUEUED UPDATES'); const firstUpdate = updateQueue.first; if (!firstUpdate) { return; @@ -324,30 +355,34 @@ var ReactNoop = { ' '.repeat(depth + 1) + '~', firstUpdate && firstUpdate.partialState, firstUpdate.callback ? 'with callback' : '', - '[' + firstUpdate.priorityLevel + ']' + '[' + firstUpdate.priorityLevel + ']', ); var next; - while (next = firstUpdate.next) { + while ((next = firstUpdate.next)) { log( ' '.repeat(depth + 1) + '~', next.partialState, next.callback ? 'with callback' : '', - '[' + firstUpdate.priorityLevel + ']' + '[' + firstUpdate.priorityLevel + ']', ); } } - function logFiber(fiber : Fiber, depth) { + function logFiber(fiber: Fiber, depth) { log( - ' '.repeat(depth) + '- ' + (fiber.type ? fiber.type.name || fiber.type : '[root]'), - '[' + fiber.pendingWorkPriority + (fiber.pendingProps ? '*' : '') + ']' + ' '.repeat(depth) + + '- ' + + (fiber.type ? fiber.type.name || fiber.type : '[root]'), + '[' + fiber.pendingWorkPriority + (fiber.pendingProps ? '*' : '') + ']', ); if (fiber.updateQueue) { logUpdateQueue(fiber.updateQueue, depth); } const childInProgress = fiber.progressedChild; if (childInProgress && childInProgress !== fiber.child) { - log(' '.repeat(depth + 1) + 'IN PROGRESS: ' + fiber.progressedPriority); + log( + ' '.repeat(depth + 1) + 'IN PROGRESS: ' + fiber.progressedPriority, + ); logFiber(childInProgress, depth + 1); if (fiber.child) { log(' '.repeat(depth + 1) + 'CURRENT'); @@ -371,7 +406,7 @@ var ReactNoop = { console.log(...bufferedLog); }, - simulateErrorInHostConfig(fn : () => void) { + simulateErrorInHostConfig(fn: () => void) { failInBeginPhase = true; try { fn(); @@ -380,6 +415,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; diff --git a/Libraries/Renderer/src/renderers/shared/ReactDebugTool.js b/Libraries/Renderer/src/renderers/shared/ReactDebugTool.js index b5ad9efeb9e1b7..7be3d38fe73fbd 100644 --- a/Libraries/Renderer/src/renderers/shared/ReactDebugTool.js +++ b/Libraries/Renderer/src/renderers/shared/ReactDebugTool.js @@ -14,8 +14,8 @@ var ReactInvalidSetStateWarningHook = require('ReactInvalidSetStateWarningHook'); var ReactHostOperationHistoryHook = require('ReactHostOperationHistoryHook'); -var ReactComponentTreeHook = require('react/lib/ReactComponentTreeHook'); var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment'); +var {ReactComponentTreeHook} = require('ReactGlobalSharedState'); var performanceNow = require('fbjs/lib/performanceNow'); var warning = require('fbjs/lib/warning'); diff --git a/Libraries/Renderer/src/renderers/shared/ReactGlobalSharedState.js b/Libraries/Renderer/src/renderers/shared/ReactGlobalSharedState.js new file mode 100644 index 00000000000000..b9107b435857e5 --- /dev/null +++ b/Libraries/Renderer/src/renderers/shared/ReactGlobalSharedState.js @@ -0,0 +1,27 @@ +/** + * Copyright 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule ReactGlobalSharedState + */ + +'use strict'; + +var ReactInternals = require('react').__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; + +var ReactGlobalSharedState = { + ReactCurrentOwner: ReactInternals.ReactCurrentOwner, +}; + +if (__DEV__) { + Object.assign(ReactGlobalSharedState, { + ReactComponentTreeHook: ReactInternals.ReactComponentTreeHook, + ReactDebugCurrentFrame: ReactInternals.ReactDebugCurrentFrame, + }); +} + +module.exports = ReactGlobalSharedState; diff --git a/Libraries/Renderer/src/renderers/shared/fiber/ReactChildFiber.js b/Libraries/Renderer/src/renderers/shared/fiber/ReactChildFiber.js index f56c80e1b9e7b4..ac6eab0138dfe1 100644 --- a/Libraries/Renderer/src/renderers/shared/fiber/ReactChildFiber.js +++ b/Libraries/Renderer/src/renderers/shared/fiber/ReactChildFiber.js @@ -36,7 +36,7 @@ var emptyObject = require('fbjs/lib/emptyObject'); var getIteratorFn = require('getIteratorFn'); var invariant = require('fbjs/lib/invariant'); var ReactFeatureFlags = require('ReactFeatureFlags'); -var ReactCurrentOwner = require('react/lib/ReactCurrentOwner'); +var {ReactCurrentOwner} = require('ReactGlobalSharedState'); if (__DEV__) { var {getCurrentFiberStackAddendum} = require('ReactDebugCurrentFiber'); diff --git a/Libraries/Renderer/src/renderers/shared/fiber/ReactFiberBeginWork.js b/Libraries/Renderer/src/renderers/shared/fiber/ReactFiberBeginWork.js index ad58d044613f23..3787e98be02d9b 100644 --- a/Libraries/Renderer/src/renderers/shared/fiber/ReactFiberBeginWork.js +++ b/Libraries/Renderer/src/renderers/shared/fiber/ReactFiberBeginWork.js @@ -60,8 +60,8 @@ var { Err, Ref, } = require('ReactTypeOfSideEffect'); -var ReactCurrentOwner = require('react/lib/ReactCurrentOwner'); var ReactFiberClassComponent = require('ReactFiberClassComponent'); +var {ReactCurrentOwner} = require('ReactGlobalSharedState'); var invariant = require('fbjs/lib/invariant'); if (__DEV__) { diff --git a/Libraries/Renderer/src/renderers/shared/fiber/ReactFiberContext.js b/Libraries/Renderer/src/renderers/shared/fiber/ReactFiberContext.js index 0f45d75323ff94..e60fdd850eb169 100644 --- a/Libraries/Renderer/src/renderers/shared/fiber/ReactFiberContext.js +++ b/Libraries/Renderer/src/renderers/shared/fiber/ReactFiberContext.js @@ -15,6 +15,7 @@ import type {Fiber} from 'ReactFiber'; import type {StackCursor} from 'ReactFiberStack'; +var React = require('react'); var emptyObject = require('fbjs/lib/emptyObject'); var getComponentName = require('getComponentName'); var invariant = require('fbjs/lib/invariant'); @@ -33,9 +34,8 @@ const { } = require('ReactFiberStack'); if (__DEV__) { - var checkReactTypeSpec = require('checkReactTypeSpec'); - var ReactDebugCurrentFrame = require('react/lib/ReactDebugCurrentFrame'); var ReactDebugCurrentFiber = require('ReactDebugCurrentFiber'); + var {ReactDebugCurrentFrame} = require('ReactGlobalSharedState'); var { startPhaseTimer, stopPhaseTimer, @@ -105,7 +105,14 @@ exports.getMaskedContext = function( if (__DEV__) { const name = getComponentName(workInProgress) || 'Unknown'; ReactDebugCurrentFrame.current = workInProgress; - checkReactTypeSpec(contextTypes, context, 'context', name); + // $FlowFixMe - We know this export exists now, need to wait for Flow update + React.checkPropTypes( + contextTypes, + context, + 'context', + name, + ReactDebugCurrentFrame.getStackAddendum, + ); ReactDebugCurrentFrame.current = null; } @@ -212,7 +219,14 @@ function processChildContext( // TODO: remove this hack when we delete unstable_renderSubtree in Fiber. const workInProgress = isReconciling ? fiber : null; ReactDebugCurrentFrame.current = workInProgress; - checkReactTypeSpec(childContextTypes, childContext, 'child context', name); + // $FlowFixMe - We know this export exists now, need to wait for Flow update + React.checkPropTypes( + childContextTypes, + childContext, + 'child context', + name, + ReactDebugCurrentFrame.getStackAddendum, + ); ReactDebugCurrentFrame.current = null; } diff --git a/Libraries/Renderer/src/renderers/shared/fiber/ReactFiberErrorLogger.js b/Libraries/Renderer/src/renderers/shared/fiber/ReactFiberErrorLogger.js index 7eb1f746b1e608..093439b6389e4a 100644 --- a/Libraries/Renderer/src/renderers/shared/fiber/ReactFiberErrorLogger.js +++ b/Libraries/Renderer/src/renderers/shared/fiber/ReactFiberErrorLogger.js @@ -98,7 +98,7 @@ function logCapturedError(capturedError: CapturedError): void { exports.injection = { /** - * Display custom dialogĀ for lifecycle errors. + * Display custom dialog for lifecycle errors. * Return false to prevent default behavior of logging to console.error. */ injectDialog(fn: (e: CapturedError) => boolean) { diff --git a/Libraries/Renderer/src/renderers/shared/fiber/ReactFiberHostContext.js b/Libraries/Renderer/src/renderers/shared/fiber/ReactFiberHostContext.js index b6252bbc0fa909..41e4ff15dfb7d5 100644 --- a/Libraries/Renderer/src/renderers/shared/fiber/ReactFiberHostContext.js +++ b/Libraries/Renderer/src/renderers/shared/fiber/ReactFiberHostContext.js @@ -16,8 +16,6 @@ import type {Fiber} from 'ReactFiber'; import type {HostConfig} from 'ReactFiberReconciler'; import type {StackCursor} from 'ReactFiberStack'; -const emptyObject = require('fbjs/lib/emptyObject'); - const { createCursor, pop, @@ -26,6 +24,9 @@ const { const invariant = require('fbjs/lib/invariant'); +declare class NoContextT {} +const NO_CONTEXT: NoContextT = ({}: any); + export type HostContext = { getHostContext(): CX, getRootHostContainer(): C, @@ -44,19 +45,27 @@ module.exports = function( getRootHostContext, } = config; - let contextStackCursor: StackCursor = createCursor((null: ?CX)); - let contextFiberStackCursor: StackCursor = createCursor( - (null: Fiber | null), + let contextStackCursor: StackCursor = createCursor( + NO_CONTEXT, + ); + let contextFiberStackCursor: StackCursor = createCursor( + NO_CONTEXT, + ); + let rootInstanceStackCursor: StackCursor = createCursor( + NO_CONTEXT, ); - let rootInstanceStackCursor: StackCursor = createCursor((null: ?C)); - function getRootHostContainer(): C { - const rootInstance = rootInstanceStackCursor.current; + function requiredContext(c: Value | NoContextT): Value { invariant( - rootInstance !== null, - 'Expected root container to exist. This error is likely caused by a ' + - 'bug in React. Please file an issue.', + c !== NO_CONTEXT, + 'Expected host context to exist. This error is likely caused by a bug ' + + 'in React. Please file an issue.', ); + return (c: any); + } + + function getRootHostContainer(): C { + const rootInstance = requiredContext(rootInstanceStackCursor.current); return rootInstance; } @@ -80,26 +89,13 @@ module.exports = function( } function getHostContext(): CX { - const context = contextStackCursor.current; - invariant( - context != null, - 'Expected host context to exist. This error is likely caused by a bug ' + - 'in React. Please file an issue.', - ); + const context = requiredContext(contextStackCursor.current); return context; } function pushHostContext(fiber: Fiber): void { - const rootInstance = rootInstanceStackCursor.current; - invariant( - rootInstance != null, - 'Expected root host context to exist. This error is likely caused by ' + - 'a bug in React. Please file an issue.', - ); - - const context = contextStackCursor.current !== null - ? contextStackCursor.current - : emptyObject; + const rootInstance = requiredContext(rootInstanceStackCursor.current); + const context = requiredContext(contextStackCursor.current); const nextContext = getChildHostContext(context, fiber.type, rootInstance); // Don't push this Fiber's context unless it's unique. @@ -125,8 +121,8 @@ module.exports = function( } function resetHostContainer() { - contextStackCursor.current = null; - rootInstanceStackCursor.current = null; + contextStackCursor.current = NO_CONTEXT; + rootInstanceStackCursor.current = NO_CONTEXT; } return { diff --git a/Libraries/Renderer/src/renderers/shared/fiber/ReactFiberScheduler.js b/Libraries/Renderer/src/renderers/shared/fiber/ReactFiberScheduler.js index 2ffc72f74b8eaa..80ff10825e5315 100644 --- a/Libraries/Renderer/src/renderers/shared/fiber/ReactFiberScheduler.js +++ b/Libraries/Renderer/src/renderers/shared/fiber/ReactFiberScheduler.js @@ -45,8 +45,8 @@ var ReactFiberBeginWork = require('ReactFiberBeginWork'); var ReactFiberCompleteWork = require('ReactFiberCompleteWork'); var ReactFiberCommitWork = require('ReactFiberCommitWork'); var ReactFiberHostContext = require('ReactFiberHostContext'); -var ReactCurrentOwner = require('react/lib/ReactCurrentOwner'); var ReactFeatureFlags = require('ReactFeatureFlags'); +var {ReactCurrentOwner} = require('ReactGlobalSharedState'); var getComponentName = require('getComponentName'); var {cloneFiber} = require('ReactFiber'); @@ -686,6 +686,8 @@ module.exports = function( } // Without this explicit null return Flow complains of invalid return type + // TODO Remove the above while(true) loop + // eslint-disable-next-line no-unreachable return null; } diff --git a/Libraries/Renderer/src/renderers/shared/fiber/ReactFiberTreeReflection.js b/Libraries/Renderer/src/renderers/shared/fiber/ReactFiberTreeReflection.js index 1cd0dea6ed7439..b527587c45ee9f 100644 --- a/Libraries/Renderer/src/renderers/shared/fiber/ReactFiberTreeReflection.js +++ b/Libraries/Renderer/src/renderers/shared/fiber/ReactFiberTreeReflection.js @@ -15,7 +15,7 @@ import type {Fiber} from 'ReactFiber'; var ReactInstanceMap = require('ReactInstanceMap'); -var ReactCurrentOwner = require('react/lib/ReactCurrentOwner'); +var {ReactCurrentOwner} = require('ReactGlobalSharedState'); var getComponentName = require('getComponentName'); var invariant = require('fbjs/lib/invariant'); diff --git a/Libraries/Renderer/src/renderers/shared/fiber/__tests__/ReactFiberHostContext-test.js b/Libraries/Renderer/src/renderers/shared/fiber/__tests__/ReactFiberHostContext-test.js new file mode 100644 index 00000000000000..b39352987c9e4c --- /dev/null +++ b/Libraries/Renderer/src/renderers/shared/fiber/__tests__/ReactFiberHostContext-test.js @@ -0,0 +1,62 @@ +/** + * Copyright 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @emails react-core + */ + +'use strict'; + +var React; +var ReactFiberReconciler; + +describe('ReactFiberHostContext', () => { + beforeEach(() => { + jest.resetModules(); + React = require('React'); + ReactFiberReconciler = require('ReactFiberReconciler'); + }); + + it('works with null host context', () => { + var creates = 0; + var Renderer = ReactFiberReconciler({ + prepareForCommit: function() {}, + resetAfterCommit: function() {}, + getRootHostContext: function() { + return null; + }, + getChildHostContext: function() { + return null; + }, + shouldSetTextContent: function() { + return false; + }, + createInstance: function() { + creates++; + }, + finalizeInitialChildren: function() { + return null; + }, + appendInitialChild: function() { + return null; + }, + appendChild: function() { + return null; + }, + useSyncScheduling: true, + }); + + const container = Renderer.createContainer(/* root: */ null); + Renderer.updateContainer( + , + container, + /* parentComponent: */ null, + /* callback: */ null, + ); + expect(creates).toBe(2); + }); +}); diff --git a/Libraries/Renderer/src/renderers/shared/stack/reconciler/ReactChildReconciler.js b/Libraries/Renderer/src/renderers/shared/stack/reconciler/ReactChildReconciler.js index 7c9a13bfd064a1..b0eedb0af95445 100644 --- a/Libraries/Renderer/src/renderers/shared/stack/reconciler/ReactChildReconciler.js +++ b/Libraries/Renderer/src/renderers/shared/stack/reconciler/ReactChildReconciler.js @@ -17,7 +17,7 @@ var ReactReconciler = require('ReactReconciler'); var instantiateReactComponent = require('instantiateReactComponent'); var shouldUpdateReactComponent = require('shouldUpdateReactComponent'); -var traverseAllChildren = require('traverseAllChildren'); +var traverseStackChildren = require('traverseStackChildren'); var warning = require('fbjs/lib/warning'); var ReactComponentTreeHook; @@ -32,7 +32,7 @@ if ( // https://github.com/facebook/react/issues/7240 // Remove the inline requires when we don't need them anymore: // https://github.com/facebook/react/pull/7178 - ReactComponentTreeHook = require('react/lib/ReactComponentTreeHook'); + ReactComponentTreeHook = require('ReactGlobalSharedState').ReactComponentTreeHook; } function instantiateChild(childInstances, child, name, selfDebugID) { @@ -40,7 +40,7 @@ function instantiateChild(childInstances, child, name, selfDebugID) { var keyUnique = childInstances[name] === undefined; if (__DEV__) { if (!ReactComponentTreeHook) { - ReactComponentTreeHook = require('react/lib/ReactComponentTreeHook'); + ReactComponentTreeHook = require('ReactGlobalSharedState').ReactComponentTreeHook; } if (!keyUnique) { warning( @@ -84,14 +84,14 @@ var ReactChildReconciler = { var childInstances = {}; if (__DEV__) { - traverseAllChildren( + traverseStackChildren( nestedChildNodes, (childInsts, child, name) => instantiateChild(childInsts, child, name, selfDebugID), childInstances, ); } else { - traverseAllChildren(nestedChildNodes, instantiateChild, childInstances); + traverseStackChildren(nestedChildNodes, instantiateChild, childInstances); } return childInstances; }, diff --git a/Libraries/Renderer/src/renderers/shared/stack/reconciler/ReactCompositeComponent.js b/Libraries/Renderer/src/renderers/shared/stack/reconciler/ReactCompositeComponent.js index 5dfcc45d440c3e..6649dffaf64b59 100644 --- a/Libraries/Renderer/src/renderers/shared/stack/reconciler/ReactCompositeComponent.js +++ b/Libraries/Renderer/src/renderers/shared/stack/reconciler/ReactCompositeComponent.js @@ -14,17 +14,16 @@ var React = require('react'); var ReactComponentEnvironment = require('ReactComponentEnvironment'); var ReactCompositeComponentTypes = require('ReactCompositeComponentTypes'); -var ReactCurrentOwner = require('react/lib/ReactCurrentOwner'); var ReactErrorUtils = require('ReactErrorUtils'); var ReactFeatureFlags = require('ReactFeatureFlags'); var ReactInstanceMap = require('ReactInstanceMap'); var ReactInstrumentation = require('ReactInstrumentation'); var ReactNodeTypes = require('ReactNodeTypes'); var ReactReconciler = require('ReactReconciler'); +var {ReactCurrentOwner} = require('ReactGlobalSharedState'); if (__DEV__) { - var checkReactTypeSpec = require('checkReactTypeSpec'); - var ReactDebugCurrentFrame = require('react/lib/ReactDebugCurrentFrame'); + var {ReactDebugCurrentFrame} = require('ReactGlobalSharedState'); var warningAboutMissingGetChildContext = {}; } @@ -730,7 +729,13 @@ var ReactCompositeComponent = { _checkContextTypes: function(typeSpecs, values, location: string) { if (__DEV__) { ReactDebugCurrentFrame.current = this._debugID; - checkReactTypeSpec(typeSpecs, values, location, this.getName()); + React.checkPropTypes( + typeSpecs, + values, + location, + this.getName(), + ReactDebugCurrentFrame.getStackAddendum, + ); ReactDebugCurrentFrame.current = null; } }, diff --git a/Libraries/Renderer/src/renderers/shared/stack/reconciler/ReactMultiChild.js b/Libraries/Renderer/src/renderers/shared/stack/reconciler/ReactMultiChild.js index 19fd366a38e61b..8bde4e26ffffaa 100644 --- a/Libraries/Renderer/src/renderers/shared/stack/reconciler/ReactMultiChild.js +++ b/Libraries/Renderer/src/renderers/shared/stack/reconciler/ReactMultiChild.js @@ -15,12 +15,12 @@ var ReactComponentEnvironment = require('ReactComponentEnvironment'); var ReactInstanceMap = require('ReactInstanceMap'); var ReactInstrumentation = require('ReactInstrumentation'); -var ReactCurrentOwner = require('react/lib/ReactCurrentOwner'); var ReactReconciler = require('ReactReconciler'); var ReactChildReconciler = require('ReactChildReconciler'); +var {ReactCurrentOwner} = require('ReactGlobalSharedState'); var emptyFunction = require('fbjs/lib/emptyFunction'); -var flattenChildren = require('flattenChildren'); +var flattenStackChildren = require('flattenStackChildren'); var invariant = require('fbjs/lib/invariant'); /** @@ -212,7 +212,7 @@ var ReactMultiChild = { if (this._currentElement) { try { ReactCurrentOwner.current = this._currentElement._owner; - nextChildren = flattenChildren( + nextChildren = flattenStackChildren( nextNestedChildrenElements, selfDebugID, ); @@ -233,7 +233,10 @@ var ReactMultiChild = { return nextChildren; } } - nextChildren = flattenChildren(nextNestedChildrenElements, selfDebugID); + nextChildren = flattenStackChildren( + nextNestedChildrenElements, + selfDebugID, + ); ReactChildReconciler.updateChildren( prevChildren, nextChildren, diff --git a/Libraries/Renderer/src/renderers/shared/stack/reconciler/ReactRef.js b/Libraries/Renderer/src/renderers/shared/stack/reconciler/ReactRef.js index cae62c717b26f3..89abe98df736f5 100644 --- a/Libraries/Renderer/src/renderers/shared/stack/reconciler/ReactRef.js +++ b/Libraries/Renderer/src/renderers/shared/stack/reconciler/ReactRef.js @@ -21,7 +21,7 @@ var ReactRef = {}; if (__DEV__) { var ReactCompositeComponentTypes = require('ReactCompositeComponentTypes'); - var ReactComponentTreeHook = require('react/lib/ReactComponentTreeHook'); + var {ReactComponentTreeHook} = require('ReactGlobalSharedState'); var warning = require('fbjs/lib/warning'); var warnedAboutStatelessRefs = {}; diff --git a/Libraries/Renderer/src/renderers/shared/stack/reconciler/ReactUpdateQueue.js b/Libraries/Renderer/src/renderers/shared/stack/reconciler/ReactUpdateQueue.js index 20cbb87fbbe404..e34cfee15b9601 100644 --- a/Libraries/Renderer/src/renderers/shared/stack/reconciler/ReactUpdateQueue.js +++ b/Libraries/Renderer/src/renderers/shared/stack/reconciler/ReactUpdateQueue.js @@ -11,10 +11,10 @@ 'use strict'; -var ReactCurrentOwner = require('react/lib/ReactCurrentOwner'); var ReactInstanceMap = require('ReactInstanceMap'); var ReactInstrumentation = require('ReactInstrumentation'); var ReactUpdates = require('ReactUpdates'); +var {ReactCurrentOwner} = require('ReactGlobalSharedState'); if (__DEV__) { var warning = require('fbjs/lib/warning'); diff --git a/Libraries/Renderer/src/shared/utils/flattenChildren.js b/Libraries/Renderer/src/renderers/shared/stack/reconciler/flattenStackChildren.js similarity index 85% rename from Libraries/Renderer/src/shared/utils/flattenChildren.js rename to Libraries/Renderer/src/renderers/shared/stack/reconciler/flattenStackChildren.js index 21a5da7140abb5..4abb79e78f0548 100644 --- a/Libraries/Renderer/src/shared/utils/flattenChildren.js +++ b/Libraries/Renderer/src/renderers/shared/stack/reconciler/flattenStackChildren.js @@ -6,14 +6,14 @@ * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. * - * @providesModule flattenChildren + * @providesModule flattenStackChildren * @flow */ 'use strict'; var KeyEscapeUtils = require('KeyEscapeUtils'); -var traverseAllChildren = require('traverseAllChildren'); +var traverseStackChildren = require('traverseStackChildren'); var warning = require('fbjs/lib/warning'); var ReactComponentTreeHook; @@ -28,7 +28,7 @@ if ( // https://github.com/facebook/react/issues/7240 // Remove the inline requires when we don't need them anymore: // https://github.com/facebook/react/pull/7178 - ReactComponentTreeHook = require('react/lib/ReactComponentTreeHook'); + ReactComponentTreeHook = require('ReactGlobalSharedState').ReactComponentTreeHook; } /** @@ -49,7 +49,7 @@ function flattenSingleChildIntoContext( const keyUnique = result[name] === undefined; if (__DEV__) { if (!ReactComponentTreeHook) { - ReactComponentTreeHook = require('react/lib/ReactComponentTreeHook'); + ReactComponentTreeHook = require('ReactGlobalSharedState').ReactComponentTreeHook; } if (!keyUnique) { warning( @@ -73,7 +73,7 @@ function flattenSingleChildIntoContext( * children will not be included in the resulting object. * @return {!object} flattened children keyed by name. */ -function flattenChildren( +function flattenStackChildren( children: ReactElement, selfDebugID?: number, ): ?{[name: string]: ReactElement} { @@ -83,7 +83,7 @@ function flattenChildren( var result = {}; if (__DEV__) { - traverseAllChildren( + traverseStackChildren( children, (traverseContext, child, name) => flattenSingleChildIntoContext( @@ -95,9 +95,9 @@ function flattenChildren( result, ); } else { - traverseAllChildren(children, flattenSingleChildIntoContext, result); + traverseStackChildren(children, flattenSingleChildIntoContext, result); } return result; } -module.exports = flattenChildren; +module.exports = flattenStackChildren; diff --git a/Libraries/Renderer/src/shared/utils/traverseAllChildren.js b/Libraries/Renderer/src/renderers/shared/stack/reconciler/traverseStackChildren.js similarity index 91% rename from Libraries/Renderer/src/shared/utils/traverseAllChildren.js rename to Libraries/Renderer/src/renderers/shared/stack/reconciler/traverseStackChildren.js index dd8b49fb580069..b717ea28fbc027 100644 --- a/Libraries/Renderer/src/shared/utils/traverseAllChildren.js +++ b/Libraries/Renderer/src/renderers/shared/stack/reconciler/traverseStackChildren.js @@ -6,13 +6,13 @@ * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. * - * @providesModule traverseAllChildren + * @providesModule traverseStackChildren */ 'use strict'; -var ReactCurrentOwner = require('react/lib/ReactCurrentOwner'); var REACT_ELEMENT_TYPE = require('ReactElementSymbol'); +var {ReactCurrentOwner} = require('ReactGlobalSharedState'); var getIteratorFn = require('getIteratorFn'); var invariant = require('fbjs/lib/invariant'); @@ -61,7 +61,7 @@ function getComponentKey(component, index) { * process. * @return {!number} The number of children in this subtree. */ -function traverseAllChildrenImpl( +function traverseStackChildrenImpl( children, nameSoFar, callback, @@ -101,7 +101,7 @@ function traverseAllChildrenImpl( for (var i = 0; i < children.length; i++) { child = children[i]; nextName = nextNamePrefix + getComponentKey(child, i); - subtreeCount += traverseAllChildrenImpl( + subtreeCount += traverseStackChildrenImpl( child, nextName, callback, @@ -140,7 +140,7 @@ function traverseAllChildrenImpl( while (!(step = iterator.next()).done) { child = step.value; nextName = nextNamePrefix + getComponentKey(child, ii++); - subtreeCount += traverseAllChildrenImpl( + subtreeCount += traverseStackChildrenImpl( child, nextName, callback, @@ -178,8 +178,8 @@ function traverseAllChildrenImpl( * Traverses children that are typically specified as `props.children`, but * might also be specified through attributes: * - * - `traverseAllChildren(this.props.children, ...)` - * - `traverseAllChildren(this.props.leftPanelChildren, ...)` + * - `traverseStackChildren(this.props.children, ...)` + * - `traverseStackChildren(this.props.leftPanelChildren, ...)` * * The `traverseContext` is an optional argument that is passed through the * entire traversal. It can be used to store accumulations or anything else that @@ -190,12 +190,12 @@ function traverseAllChildrenImpl( * @param {?*} traverseContext Context for traversal. * @return {!number} The number of children in this subtree. */ -function traverseAllChildren(children, callback, traverseContext) { +function traverseStackChildren(children, callback, traverseContext) { if (children == null) { return 0; } - return traverseAllChildrenImpl(children, '', callback, traverseContext); + return traverseStackChildrenImpl(children, '', callback, traverseContext); } -module.exports = traverseAllChildren; +module.exports = traverseStackChildren; diff --git a/Libraries/Renderer/src/renderers/shared/utils/ReactErrorUtils.js b/Libraries/Renderer/src/renderers/shared/utils/ReactErrorUtils.js index 2a08fb1124f18c..a16e885ef7c7f9 100644 --- a/Libraries/Renderer/src/renderers/shared/utils/ReactErrorUtils.js +++ b/Libraries/Renderer/src/renderers/shared/utils/ReactErrorUtils.js @@ -76,15 +76,6 @@ let rethrowCaughtError = function() { } }; -/** - * Call a function while guarding against errors that happens within it. - * Returns an error if it throws, otherwise null. - * - * @param {String} name of the guard to use for logging or debugging - * @param {Function} func The function to invoke - * @param {*} context The context to use when calling the function - * @param {...*} args Arguments for function - */ const ReactErrorUtils = { injection: { injectErrorUtils(injectedErrorUtils: Object) { @@ -96,6 +87,15 @@ const ReactErrorUtils = { }, }, + /** + * Call a function while guarding against errors that happens within it. + * Returns an error if it throws, otherwise null. + * + * @param {String} name of the guard to use for logging or debugging + * @param {Function} func The function to invoke + * @param {*} context The context to use when calling the function + * @param {...*} args Arguments for function + */ invokeGuardedCallback: function( name: string | null, func: (a: A, b: B, c: C, d: D, e: E, f: F) => void, diff --git a/Libraries/Renderer/src/shared/types/checkReactTypeSpec.js b/Libraries/Renderer/src/shared/types/checkReactTypeSpec.js deleted file mode 100644 index 131e23e1a5f8b5..00000000000000 --- a/Libraries/Renderer/src/shared/types/checkReactTypeSpec.js +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Copyright 2013-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * @providesModule checkReactTypeSpec - */ - -'use strict'; - -var checkPropTypes = require('react/lib/checkPropTypes'); -var {getStackAddendum} = require('react/lib/ReactDebugCurrentFrame'); - -function checkReactTypeSpec( - typeSpecs, - values, - location: string, - componentName, -) { - checkPropTypes(typeSpecs, values, location, componentName, getStackAddendum); -} - -module.exports = checkReactTypeSpec; diff --git a/Libraries/Renderer/src/shared/utils/getComponentName.js b/Libraries/Renderer/src/shared/utils/getComponentName.js index 76ee7278e1dc64..b5360efc230b7d 100644 --- a/Libraries/Renderer/src/shared/utils/getComponentName.js +++ b/Libraries/Renderer/src/shared/utils/getComponentName.js @@ -6,8 +6,8 @@ * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. * - * @flow * @providesModule getComponentName + * @flow */ 'use strict'; diff --git a/Libraries/react-native/React.js b/Libraries/react-native/React.js index 4dcb46b769ea1e..ba075690bf5ff8 100644 --- a/Libraries/react-native/React.js +++ b/Libraries/react-native/React.js @@ -11,4 +11,4 @@ 'use strict'; -module.exports = require('react/lib/React'); +module.exports = require('react'); diff --git a/package.json b/package.json index 5fc18048b4034c..509a2de2c1aa6d 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,6 @@ "Libraries/react-native/", "/node_modules/(?!react|fbjs|react-native|react-transform-hmr|core-js|promise)/", "node_modules/react/node_modules/fbjs/", - "node_modules/react/lib/ReactDOM.js", "node_modules/fbjs/lib/Map.js", "node_modules/fbjs/lib/Promise.js", "node_modules/fbjs/lib/fetch.js", @@ -68,7 +67,6 @@ "node_modules/fbjs/lib/sprintf.js", "node_modules/fbjs/lib/xhrSimpleDataSerializer.js", "node_modules/jest-cli", - "node_modules/react/dist", "node_modules/fbjs/.*/__mocks__/", "node_modules/fbjs/node_modules/", "/website/" @@ -219,18 +217,18 @@ "devDependencies": { "babel-eslint": "^7.1.1", "eslint": "^3.8.1", + "eslint-config-fbjs": "^1.1.1", "eslint-plugin-babel": "^3.3.0", "eslint-plugin-flowtype": "^2.20.0", "eslint-plugin-react": "^6.4.1", - "eslint-config-fbjs": "^1.1.1", "flow-bin": "^0.43.1", "jest": "19.0.2", "jest-repl": "19.0.2", "jest-runtime": "19.0.2", "mock-fs": "^3.11.0", - "react": "16.0.0-alpha.6", - "react-dom": "16.0.0-alpha.6", - "react-test-renderer": "16.0.0-alpha.6", + "react": "16.0.0-alpha.8", + "react-dom": "16.0.0-alpha.8", + "react-test-renderer": "16.0.0-alpha.8", "shelljs": "0.6.0", "sinon": "^2.0.0-pre.2" }