diff --git a/Libraries/BugReporting/dumpReactTree.js b/Libraries/BugReporting/dumpReactTree.js index 210dceff8..88a5b7f8f 100644 --- a/Libraries/BugReporting/dumpReactTree.js +++ b/Libraries/BugReporting/dumpReactTree.js @@ -11,12 +11,13 @@ */ 'use strict'; -const ReactNativeMount = require('ReactNativeMount'); +/* const getReactData = require('getReactData'); const INDENTATION_SIZE = 2; const MAX_DEPTH = 2; const MAX_STRING_LENGTH = 50; +*/ /** * Dump all React Native root views and their content. This function tries @@ -32,6 +33,12 @@ function dumpReactTree() { } function getReactTree() { + // TODO(sema): Reenable tree dumps using the Fiber tree structure. #15945684 + return ( + 'React tree dumps have been temporarily disabled while React is ' + + 'upgraded to Fiber.' + ); +/* let output = ''; const rootIds = Object.getOwnPropertyNames(ReactNativeMount._instancesByContainerID); for (const rootId of rootIds) { @@ -41,8 +48,10 @@ function getReactTree() { output += `============ End root ID: ${rootId} ============\n`; } return output; +*/ } +/* function dumpNode(node: Object, identation: number) { const data = getReactData(node); if (data.nodeType === 'Text') { @@ -101,7 +110,6 @@ function convertObject(object: Object, depth: number) { if (!first) { output += ', '; } - // $FlowFixMe(>=0.28.0) output += `${key}: ${convertValue(object[key], depth + 1)}`; first = false; } @@ -139,5 +147,6 @@ function possiblyEllipsis(value: string) { function indent(size: number) { return ' '.repeat(size * INDENTATION_SIZE); } +*/ module.exports = dumpReactTree; diff --git a/Libraries/Core/Devtools/setupDevtools.js b/Libraries/Core/Devtools/setupDevtools.js index 86722eca2..97e9240b0 100644 --- a/Libraries/Core/Devtools/setupDevtools.js +++ b/Libraries/Core/Devtools/setupDevtools.js @@ -72,28 +72,6 @@ function setupDevtools() { console.error('Failed to eval: ' + e.message); return; } - // This is breaking encapsulation of the React package. Move plz. - var ReactNativeComponentTree = require('ReactNativeComponentTree'); - window.__REACT_DEVTOOLS_GLOBAL_HOOK__.inject({ - ComponentTree: { - getClosestInstanceFromNode: function (node) { - return ReactNativeComponentTree.getClosestInstanceFromNode(node); - }, - getNodeFromInstance: function (inst) { - // inst is an internal instance (but could be a composite) - while (inst._renderedComponent) { - inst = inst._renderedComponent; - } - if (inst) { - return ReactNativeComponentTree.getNodeFromInstance(inst); - } else { - return null; - } - } - }, - Mount: require('ReactNativeMount'), - Reconciler: require('ReactReconciler') - }); ws.onmessage = handleMessage; } @@ -109,7 +87,6 @@ function setupDevtools() { // the devtools closed if (data.$close || data.$error) { closeListeners.forEach(fn => fn()); - window.__REACT_DEVTOOLS_GLOBAL_HOOK__.emit('shutdown'); tryToConnect(); return; } diff --git a/Libraries/Inspector/InspectorUtils.js b/Libraries/Inspector/InspectorUtils.js index b9ce53a3b..afc146aec 100644 --- a/Libraries/Inspector/InspectorUtils.js +++ b/Libraries/Inspector/InspectorUtils.js @@ -20,7 +20,12 @@ function traverseOwnerTreeUp(hierarchy, instance) { } function findInstanceByNativeTag(nativeTag) { - return ReactNativeComponentTree.getInstanceFromNode(nativeTag); + var instance = ReactNativeComponentTree.getInstanceFromNode(nativeTag); + if (typeof instance.tag === 'number') { + // TODO(sema): We've disabled the inspector when using Fiber. Fix #15953531 + return null; + } + return instance; } function getOwnerHierarchy(instance) { diff --git a/Libraries/StyleSheet/StyleSheetPropType.js b/Libraries/StyleSheet/StyleSheetPropType.js index 5980b8e38..5bea428c2 100644 --- a/Libraries/StyleSheet/StyleSheetPropType.js +++ b/Libraries/StyleSheet/StyleSheetPropType.js @@ -18,14 +18,14 @@ function StyleSheetPropType( shape: {[key: string]: ReactPropsCheckType} ): ReactPropsCheckType { var shapePropType = createStrictShapeTypeChecker(shape); - return function(props, propName, componentName, location?) { + return function(props, propName, componentName, location?, ...rest) { var newProps = props; if (props[propName]) { // Just make a dummy prop object with only the flattened style newProps = {}; newProps[propName] = flattenStyle(props[propName]); } - return shapePropType(newProps, propName, componentName, location); + return shapePropType(newProps, propName, componentName, location, ...rest); }; } diff --git a/Libraries/StyleSheet/StyleSheetValidation.js b/Libraries/StyleSheet/StyleSheetValidation.js index 259dd558b..7fe0f234f 100644 --- a/Libraries/StyleSheet/StyleSheetValidation.js +++ b/Libraries/StyleSheet/StyleSheetValidation.js @@ -12,13 +12,17 @@ 'use strict'; var ImageStylePropTypes = require('ImageStylePropTypes'); -var ReactPropTypeLocations = require('react/lib/ReactPropTypeLocations'); -var ReactPropTypesSecret = require('react/lib/ReactPropTypesSecret'); var TextStylePropTypes = require('TextStylePropTypes'); var ViewStylePropTypes = require('ViewStylePropTypes'); var invariant = require('fbjs/lib/invariant'); +// Hardcoded because this is a legit case but we don't want to load it from +// a private API. We might likely want to unify style sheet creation with how it +// is done in the DOM so this might move into React. I know what I'm doing so +// plz don't fire me. +const ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED'; + class StyleSheetValidation { static validateStyleProp(prop, style, caller) { if (!__DEV__) { @@ -34,9 +38,9 @@ class StyleSheetValidation { style, prop, caller, - ReactPropTypeLocations.prop, + 'prop', null, - ReactPropTypesSecret + ReactPropTypesSecret, ); if (error) { styleError(error.message, style, caller); diff --git a/Libraries/Utilities/createStrictShapeTypeChecker.js b/Libraries/Utilities/createStrictShapeTypeChecker.js index d86ce5942..884e8a96b 100644 --- a/Libraries/Utilities/createStrictShapeTypeChecker.js +++ b/Libraries/Utilities/createStrictShapeTypeChecker.js @@ -11,16 +11,13 @@ */ 'use strict'; -var ReactPropTypeLocationNames = require('react/lib/ReactPropTypeLocationNames'); -var ReactPropTypesSecret = require('react/lib/ReactPropTypesSecret'); - var invariant = require('fbjs/lib/invariant'); var merge = require('merge'); function createStrictShapeTypeChecker( shapeTypes: {[key: string]: ReactPropsCheckType} ): ReactPropsChainableTypeChecker { - function checkType(isRequired, props, propName, componentName, location?) { + function checkType(isRequired, props, propName, componentName, location?, ...rest) { if (!props[propName]) { if (isRequired) { invariant( @@ -33,8 +30,7 @@ function createStrictShapeTypeChecker( } var propValue = props[propName]; var propType = typeof propValue; - var locationName = - location && ReactPropTypeLocationNames[location] || '(unknown)'; + var locationName = location || '(unknown)'; if (propType !== 'object') { invariant( false, @@ -55,7 +51,7 @@ function createStrictShapeTypeChecker( `\nValid keys: ` + JSON.stringify(Object.keys(shapeTypes), null, ' ') ); } - var error = checker(propValue, key, componentName, location, null, ReactPropTypesSecret); + var error = checker(propValue, key, componentName, location, ...rest); if (error) { invariant( false, @@ -69,9 +65,10 @@ function createStrictShapeTypeChecker( props: {[key: string]: any}, propName: string, componentName: string, - location?: string + location?: string, + ...rest ): ?Error { - return checkType(false, props, propName, componentName, location); + return checkType(false, props, propName, componentName, location, ...rest); } chainedCheckType.isRequired = checkType.bind(null, true); return chainedCheckType; diff --git a/Libraries/Utilities/deprecatedPropType.js b/Libraries/Utilities/deprecatedPropType.js index 8bdcae77d..26a1a46bf 100644 --- a/Libraries/Utilities/deprecatedPropType.js +++ b/Libraries/Utilities/deprecatedPropType.js @@ -12,8 +12,6 @@ 'use strict'; const UIManager = require('UIManager'); -const ReactPropTypesSecret = require('react/lib/ReactPropTypesSecret'); -const ReactPropTypeLocations = require('react/lib/ReactPropTypeLocations'); /** * Adds a deprecation warning when the prop is used. @@ -22,7 +20,7 @@ function deprecatedPropType( propType: ReactPropsCheckType, explanation: string ): ReactPropsCheckType { - return function validate(props, propName, componentName) { + return function validate(props, propName, componentName, ...rest) { // Don't warn for native components. if (!UIManager[componentName] && props[propName] !== undefined) { console.warn(`\`${propName}\` supplied to \`${componentName}\` has been deprecated. ${explanation}`); @@ -32,9 +30,7 @@ function deprecatedPropType( props, propName, componentName, - ReactPropTypeLocations.prop, - null, - ReactPropTypesSecret + ...rest ); }; } diff --git a/Libraries/react-native/react-native.js b/Libraries/react-native/react-native.js index 88c418776..af7d51298 100644 --- a/Libraries/react-native/react-native.js +++ b/Libraries/react-native/react-native.js @@ -120,12 +120,6 @@ const ReactNative = { // See http://facebook.github.io/react/docs/addons.html addons: { - get LinkedStateMixin() { - if (__DEV__) { - addonWarn('LinkedStateMixin', 'react-addons-linked-state-mixin'); - } - return require('react/lib/LinkedStateMixin'); - }, get PureRenderMixin() { if (__DEV__) { addonWarn('PureRenderMixin', 'react-addons-pure-render-mixin'); diff --git a/jest/setup.js b/jest/setup.js index c8fbe8114..ee7ae562a 100644 --- a/jest/setup.js +++ b/jest/setup.js @@ -27,7 +27,7 @@ jest jest.setMock('ErrorUtils', require('ErrorUtils')); jest - .mock('ReactNativeDefaultInjection') + .mock('InitializeCore') .mock('Image', () => mockComponent('Image')) .mock('Text', () => mockComponent('Text')) .mock('TextInput', () => mockComponent('TextInput')) @@ -50,7 +50,7 @@ jest Object.keys(dataBlob).forEach(key => { this.items += dataBlob[key] && ( dataBlob[key].length || dataBlob[key].size || 0 - ) + ); }); } catch (e) { this.items = 'unknown';