(fn: () => T): T {
- return flushSync(fn);
- },
- };
-
- Object.defineProperty(
- entry,
- 'root',
- ({
- configurable: true,
- enumerable: true,
- get: function() {
- if (root === null) {
- throw new Error("Can't access .root on unmounted test renderer");
- }
- const children = getChildren(root.current);
- if (children.length === 0) {
- throw new Error("Can't access .root on unmounted test renderer");
- } else if (children.length === 1) {
- // Normally, we skip the root and just give you the child.
- return children[0];
- } else {
- // However, we give you the root if there's more than one root child.
- // We could make this the behavior for all cases but it would be a breaking change.
- return wrapFiber(root.current);
- }
- },
- }: Object),
- );
-
- return entry;
- },
-
- /* eslint-disable-next-line camelcase */
- unstable_batchedUpdates: batchedUpdates,
-
- act,
-};
+ return entry;
+}
const fiberToWrapper = new WeakMap();
function wrapFiber(fiber: Fiber): ReactTestInstance {
@@ -589,4 +581,10 @@ injectIntoDevTools({
rendererPackageName: 'react-test-renderer',
});
-export default ReactTestRendererFiber;
+export {
+ Scheduler as _Scheduler,
+ create,
+ /* eslint-disable-next-line camelcase */
+ batchedUpdates as unstable_batchedUpdates,
+ act,
+};
diff --git a/packages/react-test-renderer/src/__tests__/ReactShallowRenderer-test.js b/packages/react-test-renderer/src/__tests__/ReactShallowRenderer-test.js
index 68c8299cfe963..13aa7682aff2c 100644
--- a/packages/react-test-renderer/src/__tests__/ReactShallowRenderer-test.js
+++ b/packages/react-test-renderer/src/__tests__/ReactShallowRenderer-test.js
@@ -10,19 +10,13 @@
'use strict';
-let createRenderer;
-let PropTypes;
-let React;
+import * as PropTypes from 'prop-types';
+import * as React from 'react';
+import ReactShallowRenderer from 'react-test-renderer/shallow';
-describe('ReactShallowRenderer', () => {
- beforeEach(() => {
- jest.resetModules();
-
- createRenderer = require('react-test-renderer/shallow').createRenderer;
- PropTypes = require('prop-types');
- React = require('react');
- });
+const createRenderer = ReactShallowRenderer.createRenderer;
+describe('ReactShallowRenderer', () => {
it('should call all of the legacy lifecycle hooks', () => {
const logs = [];
const logger = message => () => logs.push(message) || true;
diff --git a/packages/react-test-renderer/src/__tests__/ReactShallowRendererHooks-test.js b/packages/react-test-renderer/src/__tests__/ReactShallowRendererHooks-test.js
index 6b8a962ad5b14..87bbdade2507c 100644
--- a/packages/react-test-renderer/src/__tests__/ReactShallowRendererHooks-test.js
+++ b/packages/react-test-renderer/src/__tests__/ReactShallowRendererHooks-test.js
@@ -10,16 +10,12 @@
'use strict';
-let createRenderer;
-let React;
+import * as React from 'react';
+import ReactShallowRenderer from 'react-test-renderer/shallow';
-describe('ReactShallowRenderer with hooks', () => {
- beforeEach(() => {
- jest.resetModules();
- createRenderer = require('react-test-renderer/shallow').createRenderer;
- React = require('react');
- });
+const createRenderer = ReactShallowRenderer.createRenderer;
+describe('ReactShallowRenderer with hooks', () => {
it('should work with useState', () => {
function SomeComponent({defaultName}) {
const [name] = React.useState(defaultName);
diff --git a/packages/react-test-renderer/src/__tests__/ReactShallowRendererMemo-test.js b/packages/react-test-renderer/src/__tests__/ReactShallowRendererMemo-test.js
index 9ed3bc681593b..5da98d8a7420a 100644
--- a/packages/react-test-renderer/src/__tests__/ReactShallowRendererMemo-test.js
+++ b/packages/react-test-renderer/src/__tests__/ReactShallowRendererMemo-test.js
@@ -10,19 +10,13 @@
'use strict';
-let createRenderer;
-let PropTypes;
-let React;
+import * as PropTypes from 'prop-types';
+import * as React from 'react';
+import ReactShallowRenderer from 'react-test-renderer/shallow';
-describe('ReactShallowRendererMemo', () => {
- beforeEach(() => {
- jest.resetModules();
-
- createRenderer = require('react-test-renderer/shallow').createRenderer;
- PropTypes = require('prop-types');
- React = require('react');
- });
+const createRenderer = ReactShallowRenderer.createRenderer;
+describe('ReactShallowRendererMemo', () => {
it('should call all of the legacy lifecycle hooks', () => {
const logs = [];
const logger = message => () => logs.push(message) || true;
diff --git a/packages/react-test-renderer/src/__tests__/ReactTestRenderer-test.internal.js b/packages/react-test-renderer/src/__tests__/ReactTestRenderer-test.internal.js
index d9c8d5b1c5208..06f7131f2bd59 100644
--- a/packages/react-test-renderer/src/__tests__/ReactTestRenderer-test.internal.js
+++ b/packages/react-test-renderer/src/__tests__/ReactTestRenderer-test.internal.js
@@ -1022,4 +1022,14 @@ describe('ReactTestRenderer', () => {
expect(Scheduler).toFlushWithoutYielding();
ReactTestRenderer.create();
});
+
+ it('calling findByType() with an invalid component will fall back to "Unknown" for component name', () => {
+ const App = () => null;
+ const renderer = ReactTestRenderer.create();
+ const NonComponent = {};
+
+ expect(() => {
+ renderer.root.findByType(NonComponent);
+ }).toThrowError(`No instances found with node type: "Unknown"`);
+ });
});
diff --git a/packages/react/index.classic.fb.js b/packages/react/index.classic.fb.js
new file mode 100644
index 0000000000000..e0d720efe846d
--- /dev/null
+++ b/packages/react/index.classic.fb.js
@@ -0,0 +1,55 @@
+/**
+ * Copyright (c) Facebook, Inc. and its affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ *
+ * @flow
+ */
+
+export {
+ Children,
+ createRef,
+ Component,
+ PureComponent,
+ createContext,
+ forwardRef,
+ lazy,
+ memo,
+ useCallback,
+ useContext,
+ useEffect,
+ useImperativeHandle,
+ useDebugValue,
+ useLayoutEffect,
+ useMemo,
+ useReducer,
+ useRef,
+ useState,
+ Fragment,
+ Profiler,
+ StrictMode,
+ Suspense,
+ createElement,
+ cloneElement,
+ isValidElement,
+ version,
+ __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
+ createFactory,
+ // exposeConcurrentModeAPIs
+ useTransition,
+ useDeferredValue,
+ SuspenseList,
+ unstable_withSuspenseConfig,
+ // enableBlocksAPI
+ block,
+ // enableDeprecatedFlareAPI
+ DEPRECATED_useResponder,
+ DEPRECATED_createResponder,
+ // enableScopeAPI
+ unstable_createScope,
+ // enableJSXTransformAPI
+ jsx,
+ jsxs,
+ jsxDEV,
+} from './src/React';
diff --git a/packages/react/index.experimental.js b/packages/react/index.experimental.js
new file mode 100644
index 0000000000000..e348f332b7f76
--- /dev/null
+++ b/packages/react/index.experimental.js
@@ -0,0 +1,46 @@
+/**
+ * Copyright (c) Facebook, Inc. and its affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ *
+ * @flow
+ */
+
+export {
+ Children,
+ createRef,
+ Component,
+ PureComponent,
+ createContext,
+ forwardRef,
+ lazy,
+ memo,
+ useCallback,
+ useContext,
+ useEffect,
+ useImperativeHandle,
+ useDebugValue,
+ useLayoutEffect,
+ useMemo,
+ useReducer,
+ useRef,
+ useState,
+ Fragment,
+ Profiler,
+ StrictMode,
+ Suspense,
+ createElement,
+ cloneElement,
+ isValidElement,
+ version,
+ __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
+ createFactory,
+ // exposeConcurrentModeAPIs
+ useTransition,
+ useDeferredValue,
+ SuspenseList,
+ unstable_withSuspenseConfig,
+ // enableBlocksAPI
+ block,
+} from './src/React';
diff --git a/packages/react/index.js b/packages/react/index.js
index 4268898c088b9..c0dd6bbdb3c35 100644
--- a/packages/react/index.js
+++ b/packages/react/index.js
@@ -7,10 +7,74 @@
* @flow
*/
-'use strict';
+// Keep in sync with https://github.com/facebook/flow/blob/master/lib/react.js
+export type StatelessFunctionalComponent<
+ P,
+> = React$StatelessFunctionalComponent;
+export type ComponentType<-P> = React$ComponentType
;
+export type AbstractComponent<
+ -Config,
+ +Instance = mixed,
+> = React$AbstractComponent;
+export type ElementType = React$ElementType;
+export type Element<+C> = React$Element;
+export type Key = React$Key;
+export type Ref = React$Ref;
+export type Node = React$Node;
+export type Context = React$Context;
+export type Portal = React$Portal;
+export type ElementProps = React$ElementProps;
+export type ElementConfig = React$ElementConfig;
+export type ElementRef = React$ElementRef;
+export type Config = React$Config;
+export type ChildrenArray<+T> = $ReadOnlyArray> | T;
+export type Interaction = {
+ name: string,
+ timestamp: number,
+ ...
+};
-const React = require('./src/React');
-
-// TODO: decide on the top-level export form.
-// This is hacky but makes it work with both Rollup and Jest.
-module.exports = React.default || React;
+// Export all exports so that they're available in tests.
+// We can't use export * from in Flow for some reason.
+export {
+ Children,
+ createRef,
+ Component,
+ PureComponent,
+ createContext,
+ forwardRef,
+ lazy,
+ memo,
+ useCallback,
+ useContext,
+ useEffect,
+ useImperativeHandle,
+ useDebugValue,
+ useLayoutEffect,
+ useMemo,
+ useReducer,
+ useRef,
+ useState,
+ Fragment,
+ Profiler,
+ StrictMode,
+ Suspense,
+ createElement,
+ cloneElement,
+ isValidElement,
+ version,
+ __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
+ createFactory,
+ useTransition,
+ useDeferredValue,
+ SuspenseList,
+ unstable_withSuspenseConfig,
+ block,
+ DEPRECATED_useResponder,
+ DEPRECATED_createResponder,
+ unstable_createFundamental,
+ unstable_createScope,
+ jsx,
+ jsxs,
+ jsxDEV,
+} from './src/React';
diff --git a/packages/react/index.modern.fb.js b/packages/react/index.modern.fb.js
new file mode 100644
index 0000000000000..0c6ba986e2e08
--- /dev/null
+++ b/packages/react/index.modern.fb.js
@@ -0,0 +1,54 @@
+/**
+ * Copyright (c) Facebook, Inc. and its affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ *
+ * @flow
+ */
+
+export {
+ Children,
+ createRef,
+ Component,
+ PureComponent,
+ createContext,
+ forwardRef,
+ lazy,
+ memo,
+ useCallback,
+ useContext,
+ useEffect,
+ useImperativeHandle,
+ useDebugValue,
+ useLayoutEffect,
+ useMemo,
+ useReducer,
+ useRef,
+ useState,
+ Fragment,
+ Profiler,
+ StrictMode,
+ Suspense,
+ createElement,
+ cloneElement,
+ isValidElement,
+ version,
+ __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
+ // exposeConcurrentModeAPIs
+ useTransition,
+ useDeferredValue,
+ SuspenseList,
+ unstable_withSuspenseConfig,
+ // enableBlocksAPI
+ block,
+ // enableDeprecatedFlareAPI
+ DEPRECATED_useResponder,
+ DEPRECATED_createResponder,
+ // enableScopeAPI
+ unstable_createScope,
+ // enableJSXTransformAPI
+ jsx,
+ jsxs,
+ jsxDEV,
+} from './src/React';
diff --git a/packages/react/index.stable.js b/packages/react/index.stable.js
new file mode 100644
index 0000000000000..67a221ca674b7
--- /dev/null
+++ b/packages/react/index.stable.js
@@ -0,0 +1,39 @@
+/**
+ * Copyright (c) Facebook, Inc. and its affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ *
+ * @flow
+ */
+
+export {
+ Children,
+ createRef,
+ Component,
+ PureComponent,
+ createContext,
+ forwardRef,
+ lazy,
+ memo,
+ useCallback,
+ useContext,
+ useEffect,
+ useImperativeHandle,
+ useDebugValue,
+ useLayoutEffect,
+ useMemo,
+ useReducer,
+ useRef,
+ useState,
+ Fragment,
+ Profiler,
+ StrictMode,
+ Suspense,
+ createElement,
+ cloneElement,
+ isValidElement,
+ version,
+ __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
+ createFactory,
+} from './src/React';
diff --git a/packages/react/npm/testing.js b/packages/react/npm/testing.js
deleted file mode 100644
index f20bb1d19db68..0000000000000
--- a/packages/react/npm/testing.js
+++ /dev/null
@@ -1,7 +0,0 @@
-'use strict';
-
-if (process.env.NODE_ENV === 'production') {
- module.exports = require('./cjs/react-testing.production.min.js');
-} else {
- module.exports = require('./cjs/react-testing.development.js');
-}
diff --git a/packages/react/package.json b/packages/react/package.json
index a1d1a21e0d93d..2ffa23333ad2a 100644
--- a/packages/react/package.json
+++ b/packages/react/package.json
@@ -4,7 +4,7 @@
"keywords": [
"react"
],
- "version": "16.12.0",
+ "version": "16.13.0",
"homepage": "https://reactjs.org/",
"bugs": "https://github.com/facebook/react/issues",
"license": "MIT",
@@ -27,8 +27,7 @@
},
"dependencies": {
"loose-envify": "^1.1.0",
- "object-assign": "^4.1.1",
- "prop-types": "^15.6.2"
+ "object-assign": "^4.1.1"
},
"browserify": {
"transform": [
diff --git a/packages/react/src/React.js b/packages/react/src/React.js
index ad515bd321dfc..3fd7304f99398 100644
--- a/packages/react/src/React.js
+++ b/packages/react/src/React.js
@@ -18,17 +18,17 @@ import {Component, PureComponent} from './ReactBaseClasses';
import {createRef} from './ReactCreateRef';
import {forEach, map, count, toArray, only} from './ReactChildren';
import {
- createElement,
- createFactory,
- cloneElement,
+ createElement as createElementProd,
+ createFactory as createFactoryProd,
+ cloneElement as cloneElementProd,
isValidElement,
- jsx,
+ jsx as jsxProd,
} from './ReactElement';
import {createContext} from './ReactContext';
import {lazy} from './ReactLazy';
import forwardRef from './forwardRef';
import memo from './memo';
-import chunk from './chunk';
+import block from './block';
import {
useCallback,
useContext,
@@ -57,33 +57,35 @@ import ReactSharedInternals from './ReactSharedInternals';
import createFundamental from 'shared/createFundamentalComponent';
import createResponder from 'shared/createEventResponder';
import createScope from 'shared/createScope';
-import {
- enableJSXTransformAPI,
- enableDeprecatedFlareAPI,
- enableFundamentalAPI,
- enableScopeAPI,
- exposeConcurrentModeAPIs,
- enableChunksAPI,
- disableCreateFactory,
-} from 'shared/ReactFeatureFlags';
-const React = {
- Children: {
- map,
- forEach,
- count,
- toArray,
- only,
- },
+// TODO: Move this branching into the other module instead and just re-export.
+const createElement = __DEV__ ? createElementWithValidation : createElementProd;
+const cloneElement = __DEV__ ? cloneElementWithValidation : cloneElementProd;
+const createFactory = __DEV__ ? createFactoryWithValidation : createFactoryProd;
+
+const jsxDEV = __DEV__ ? jsxWithValidation : undefined;
+const jsx = __DEV__ ? jsxWithValidationDynamic : jsxProd;
+// we may want to special case jsxs internally to take advantage of static children.
+// for now we can ship identical prod functions
+const jsxs = __DEV__ ? jsxWithValidationStatic : jsxProd;
+
+const Children = {
+ map,
+ forEach,
+ count,
+ toArray,
+ only,
+};
+
+export {
+ Children,
createRef,
Component,
PureComponent,
-
createContext,
forwardRef,
lazy,
memo,
-
useCallback,
useContext,
useEffect,
@@ -94,65 +96,34 @@ const React = {
useReducer,
useRef,
useState,
-
- Fragment: REACT_FRAGMENT_TYPE,
- Profiler: REACT_PROFILER_TYPE,
- StrictMode: REACT_STRICT_MODE_TYPE,
- Suspense: REACT_SUSPENSE_TYPE,
-
- createElement: __DEV__ ? createElementWithValidation : createElement,
- cloneElement: __DEV__ ? cloneElementWithValidation : cloneElement,
- isValidElement: isValidElement,
-
- version: ReactVersion,
-
- __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: ReactSharedInternals,
+ REACT_FRAGMENT_TYPE as Fragment,
+ REACT_PROFILER_TYPE as Profiler,
+ REACT_STRICT_MODE_TYPE as StrictMode,
+ REACT_SUSPENSE_TYPE as Suspense,
+ createElement,
+ cloneElement,
+ isValidElement,
+ ReactVersion as version,
+ ReactSharedInternals as __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
+ // Deprecated behind disableCreateFactory
+ createFactory,
+ // Concurrent Mode
+ useTransition,
+ useDeferredValue,
+ REACT_SUSPENSE_LIST_TYPE as SuspenseList,
+ withSuspenseConfig as unstable_withSuspenseConfig,
+ // enableBlocksAPI
+ block,
+ // enableDeprecatedFlareAPI
+ useResponder as DEPRECATED_useResponder,
+ createResponder as DEPRECATED_createResponder,
+ // enableFundamentalAPI
+ createFundamental as unstable_createFundamental,
+ // enableScopeAPI
+ createScope as unstable_createScope,
+ // enableJSXTransformAPI
+ jsx,
+ jsxs,
+ // TODO: jsxDEV should not be exposed as a name. We might want to move it to a different entry point.
+ jsxDEV,
};
-
-if (!disableCreateFactory) {
- React.createFactory = __DEV__ ? createFactoryWithValidation : createFactory;
-}
-
-if (exposeConcurrentModeAPIs) {
- React.useTransition = useTransition;
- React.useDeferredValue = useDeferredValue;
- React.SuspenseList = REACT_SUSPENSE_LIST_TYPE;
- React.unstable_withSuspenseConfig = withSuspenseConfig;
-}
-
-if (enableChunksAPI) {
- React.chunk = chunk;
-}
-
-if (enableDeprecatedFlareAPI) {
- React.DEPRECATED_useResponder = useResponder;
- React.DEPRECATED_createResponder = createResponder;
-}
-
-if (enableFundamentalAPI) {
- React.unstable_createFundamental = createFundamental;
-}
-
-if (enableScopeAPI) {
- React.unstable_createScope = createScope;
-}
-
-// Note: some APIs are added with feature flags.
-// Make sure that stable builds for open source
-// don't modify the React object to avoid deopts.
-// Also let's not expose their names in stable builds.
-
-if (enableJSXTransformAPI) {
- if (__DEV__) {
- React.jsxDEV = jsxWithValidation;
- React.jsx = jsxWithValidationDynamic;
- React.jsxs = jsxWithValidationStatic;
- } else {
- React.jsx = jsx;
- // we may want to special case jsxs internally to take advantage of static children.
- // for now we can ship identical prod functions
- React.jsxs = jsx;
- }
-}
-
-export default React;
diff --git a/packages/react/src/ReactElementValidator.js b/packages/react/src/ReactElementValidator.js
index fa00f30d47d91..c81ace3c6b2f7 100644
--- a/packages/react/src/ReactElementValidator.js
+++ b/packages/react/src/ReactElementValidator.js
@@ -21,7 +21,8 @@ import {
REACT_FRAGMENT_TYPE,
REACT_ELEMENT_TYPE,
} from 'shared/ReactSymbols';
-import checkPropTypes from 'prop-types/checkPropTypes';
+import {warnAboutSpreadingKeyToJSX} from 'shared/ReactFeatureFlags';
+import checkPropTypes from 'shared/checkPropTypes';
import ReactCurrentOwner from './ReactCurrentOwner';
import {
@@ -30,9 +31,7 @@ import {
cloneElement,
jsxDEV,
} from './ReactElement';
-import ReactDebugCurrentFrame, {
- setCurrentlyValidatingElement,
-} from './ReactDebugCurrentFrame';
+import {setCurrentlyValidatingElement} from './ReactDebugCurrentFrame';
let propTypesMisspellWarningShown;
@@ -212,13 +211,7 @@ function validatePropTypes(element) {
}
if (propTypes) {
setCurrentlyValidatingElement(element);
- checkPropTypes(
- propTypes,
- element.props,
- 'prop',
- name,
- ReactDebugCurrentFrame.getStackAddendum,
- );
+ checkPropTypes(propTypes, element.props, 'prop', name);
setCurrentlyValidatingElement(null);
} else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {
propTypesMisspellWarningShown = true;
@@ -365,13 +358,16 @@ export function jsxWithValidation(
}
}
- if (hasOwnProperty.call(props, 'key')) {
- if (__DEV__) {
- console.error(
- 'React.jsx: Spreading a key to JSX is a deprecated pattern. ' +
- 'Explicitly pass a key after spreading props in your JSX call. ' +
- 'E.g. ',
- );
+ if (__DEV__) {
+ if (warnAboutSpreadingKeyToJSX) {
+ if (hasOwnProperty.call(props, 'key')) {
+ console.error(
+ 'React.jsx: Spreading a key to JSX is a deprecated pattern. ' +
+ 'Explicitly pass a key after spreading props in your JSX call. ' +
+ 'E.g. <%s {...props} key={key} />',
+ getComponentName(type) || 'ComponentName',
+ );
+ }
}
}
diff --git a/packages/react/src/__tests__/ReactElement-test.js b/packages/react/src/__tests__/ReactElement-test.js
index af99767220a1c..6c3d4f6cebae0 100644
--- a/packages/react/src/__tests__/ReactElement-test.js
+++ b/packages/react/src/__tests__/ReactElement-test.js
@@ -13,8 +13,6 @@ let React;
let ReactDOM;
let ReactTestUtils;
-const ReactFeatureFlags = require('shared/ReactFeatureFlags');
-
describe('ReactElement', () => {
let ComponentClass;
let originalSymbol;
@@ -312,7 +310,7 @@ describe('ReactElement', () => {
expect(React.isValidElement(true)).toEqual(false);
expect(React.isValidElement({})).toEqual(false);
expect(React.isValidElement('string')).toEqual(false);
- if (!ReactFeatureFlags.disableCreateFactory) {
+ if (!__EXPERIMENTAL__) {
let factory;
expect(() => {
factory = React.createFactory('div');
@@ -481,7 +479,7 @@ describe('ReactElement', () => {
expect(React.isValidElement(true)).toEqual(false);
expect(React.isValidElement({})).toEqual(false);
expect(React.isValidElement('string')).toEqual(false);
- if (!ReactFeatureFlags.disableCreateFactory) {
+ if (!__EXPERIMENTAL__) {
let factory;
expect(() => {
factory = React.createFactory('div');
diff --git a/packages/react/src/__tests__/ReactElementJSX-test.internal.js b/packages/react/src/__tests__/ReactElementJSX-test.internal.js
index fce448208c0dc..4a02bbc1a379d 100644
--- a/packages/react/src/__tests__/ReactElementJSX-test.internal.js
+++ b/packages/react/src/__tests__/ReactElementJSX-test.internal.js
@@ -31,7 +31,7 @@ describe('ReactElement.jsx', () => {
global.Symbol = undefined;
ReactFeatureFlags = require('shared/ReactFeatureFlags');
- ReactFeatureFlags.enableJSXTransformAPI = true;
+ ReactFeatureFlags.warnAboutSpreadingKeyToJSX = true;
React = require('react');
ReactDOM = require('react-dom');
@@ -42,6 +42,11 @@ describe('ReactElement.jsx', () => {
global.Symbol = originalSymbol;
});
+ if (!__EXPERIMENTAL__) {
+ it("empty test so Jest doesn't complain", () => {});
+ return;
+ }
+
it('allows static methods to be called using the type property', () => {
class StaticMethodComponentClass extends React.Component {
render() {
@@ -68,7 +73,7 @@ describe('ReactElement.jsx', () => {
expect(React.isValidElement(true)).toEqual(false);
expect(React.isValidElement({})).toEqual(false);
expect(React.isValidElement('string')).toEqual(false);
- if (!ReactFeatureFlags.disableCreateFactory) {
+ if (!__EXPERIMENTAL__) {
let factory;
expect(() => {
factory = React.createFactory('div');
@@ -291,9 +296,6 @@ describe('ReactElement.jsx', () => {
jest.resetModules();
- ReactFeatureFlags = require('shared/ReactFeatureFlags');
- ReactFeatureFlags.enableJSXTransformAPI = true;
-
React = require('react');
class Component extends React.Component {
@@ -309,7 +311,7 @@ describe('ReactElement.jsx', () => {
expect(React.isValidElement(true)).toEqual(false);
expect(React.isValidElement({})).toEqual(false);
expect(React.isValidElement('string')).toEqual(false);
- if (!ReactFeatureFlags.disableCreateFactory) {
+ if (!__EXPERIMENTAL__) {
let factory;
expect(() => {
factory = React.createFactory('div');
@@ -371,7 +373,7 @@ describe('ReactElement.jsx', () => {
expect(() => ReactDOM.render(React.jsx(Parent, {}), container)).toErrorDev(
'Warning: React.jsx: Spreading a key to JSX is a deprecated pattern. ' +
'Explicitly pass a key after spreading props in your JSX call. ' +
- 'E.g. ',
+ 'E.g. ',
);
});
diff --git a/packages/react/src/__tests__/ReactElementValidator-test.internal.js b/packages/react/src/__tests__/ReactElementValidator-test.internal.js
index c4016387e159e..c563e6ce6fea7 100644
--- a/packages/react/src/__tests__/ReactElementValidator-test.internal.js
+++ b/packages/react/src/__tests__/ReactElementValidator-test.internal.js
@@ -399,7 +399,6 @@ describe('ReactElementValidator', () => {
'returned a function. You may have forgotten to pass an argument to ' +
'the type checker creator (arrayOf, instanceOf, objectOf, oneOf, ' +
'oneOfType, and shape all require an argument).',
- {withoutStack: true},
);
});
@@ -439,7 +438,7 @@ describe('ReactElementValidator', () => {
);
});
- if (!ReactFeatureFlags.disableCreateFactory) {
+ if (!__EXPERIMENTAL__) {
it('should warn when accessing .type on an element factory', () => {
function TestComponent() {
return ;
diff --git a/packages/react/src/__tests__/createReactClassIntegration-test.internal.js b/packages/react/src/__tests__/createReactClassIntegration-test.internal.js
deleted file mode 100644
index 3ea37ce80a373..0000000000000
--- a/packages/react/src/__tests__/createReactClassIntegration-test.internal.js
+++ /dev/null
@@ -1,74 +0,0 @@
-/**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @emails react-core
- */
-
-'use strict';
-
-describe('create-react-class-integration', () => {
- describe('ReactNative NativeMethodsMixin', () => {
- let React;
- let ReactNative;
- let NativeMethodsMixin;
- let createReactClass;
-
- beforeEach(() => {
- jest.resetModules();
-
- React = require('react');
-
- createReactClass = require('create-react-class/factory')(
- React.Component,
- React.isValidElement,
- new React.Component().updater,
- );
-
- ReactNative = require('react-native-renderer');
- NativeMethodsMixin =
- ReactNative.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
- .NativeMethodsMixin;
- });
-
- it('should not warn about default DEV-only legacy lifecycle methods', () => {
- const View = createReactClass({
- mixins: [NativeMethodsMixin],
- render: () => null,
- });
-
- ReactNative.render(, 1);
- });
-
- it('should warn if users specify their own legacy componentWillMount', () => {
- const View = createReactClass({
- displayName: 'MyNativeComponent',
- mixins: [NativeMethodsMixin],
- componentWillMount: () => {},
- render: () => null,
- });
-
- expect(() =>
- ReactNative.render(, 1),
- ).toWarnDev('componentWillMount has been renamed', {withoutStack: true});
- });
-
- it('should warn if users specify their own legacy componentWillReceiveProps', () => {
- const View = createReactClass({
- displayName: 'MyNativeComponent',
- mixins: [NativeMethodsMixin],
- componentWillReceiveProps: () => {},
- render: () => null,
- });
-
- expect(() => ReactNative.render(, 1)).toWarnDev(
- 'componentWillReceiveProps has been renamed',
- {
- withoutStack: true,
- },
- );
- });
- });
-});
diff --git a/packages/react/src/chunk.js b/packages/react/src/block.js
similarity index 74%
rename from packages/react/src/chunk.js
rename to packages/react/src/block.js
index 90bf8ac56ffdb..575f8b66ea322 100644
--- a/packages/react/src/chunk.js
+++ b/packages/react/src/block.js
@@ -6,47 +6,47 @@
*/
import {
- REACT_CHUNK_TYPE,
+ REACT_BLOCK_TYPE,
REACT_MEMO_TYPE,
REACT_FORWARD_REF_TYPE,
} from 'shared/ReactSymbols';
-opaque type Chunk: React$AbstractComponent<
+opaque type Block: React$AbstractComponent<
Props,
null,
> = React$AbstractComponent;
-export default function chunk(
+export default function block(
query: (...args: Args) => Data,
render: (props: Props, data: Data) => React$Node,
-): (...args: Args) => Chunk {
+): (...args: Args) => Block {
if (__DEV__) {
if (typeof query !== 'function') {
console.error(
- 'Chunks require a query function but was given %s.',
+ 'Blocks require a query function but was given %s.',
query === null ? 'null' : typeof query,
);
}
if (render != null && render.$$typeof === REACT_MEMO_TYPE) {
console.error(
- 'Chunks require a render function but received a `memo` ' +
+ 'Blocks require a render function but received a `memo` ' +
'component. Use `memo` on an inner component instead.',
);
} else if (render != null && render.$$typeof === REACT_FORWARD_REF_TYPE) {
console.error(
- 'Chunks require a render function but received a `forwardRef` ' +
+ 'Blocks require a render function but received a `forwardRef` ' +
'component. Use `forwardRef` on an inner component instead.',
);
} else if (typeof render !== 'function') {
console.error(
- 'Chunks require a render function but was given %s.',
+ 'Blocks require a render function but was given %s.',
render === null ? 'null' : typeof render,
);
} else if (render.length !== 0 && render.length !== 2) {
// Warn if it's not accepting two args.
// Do not warn for 0 arguments because it could be due to usage of the 'arguments' object
console.error(
- 'Chunk render functions accept exactly two parameters: props and data. %s',
+ 'Block render functions accept exactly two parameters: props and data. %s',
render.length === 1
? 'Did you forget to use the data parameter?'
: 'Any additional parameter will be undefined.',
@@ -58,15 +58,15 @@ export default function chunk(
(render.defaultProps != null || render.propTypes != null)
) {
console.error(
- 'Chunk render functions do not support propTypes or defaultProps. ' +
+ 'Block render functions do not support propTypes or defaultProps. ' +
'Did you accidentally pass a React component?',
);
}
}
- return function(): Chunk {
+ return function(): Block {
let args = arguments;
return {
- $$typeof: REACT_CHUNK_TYPE,
+ $$typeof: REACT_BLOCK_TYPE,
query: function() {
return query.apply(null, args);
},
diff --git a/packages/react/testing.js b/packages/react/testing.js
deleted file mode 100644
index 4268898c088b9..0000000000000
--- a/packages/react/testing.js
+++ /dev/null
@@ -1,16 +0,0 @@
-/**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @flow
- */
-
-'use strict';
-
-const React = require('./src/React');
-
-// TODO: decide on the top-level export form.
-// This is hacky but makes it work with both Rollup and Jest.
-module.exports = React.default || React;
diff --git a/packages/scheduler/package.json b/packages/scheduler/package.json
index 81315b6d5e0b9..7965e3171911a 100644
--- a/packages/scheduler/package.json
+++ b/packages/scheduler/package.json
@@ -1,6 +1,6 @@
{
"name": "scheduler",
- "version": "0.18.0",
+ "version": "0.19.0",
"description": "Cooperative scheduler for the browser environment.",
"main": "index.js",
"repository": {
diff --git a/packages/shared/ReactFeatureFlags.js b/packages/shared/ReactFeatureFlags.js
index 34eabf28e9ec8..b8b656632e612 100644
--- a/packages/shared/ReactFeatureFlags.js
+++ b/packages/shared/ReactFeatureFlags.js
@@ -31,7 +31,7 @@ export const enableSuspenseServerRenderer = __EXPERIMENTAL__;
export const enableSelectiveHydration = __EXPERIMENTAL__;
// Flight experiments
-export const enableChunksAPI = __EXPERIMENTAL__;
+export const enableBlocksAPI = __EXPERIMENTAL__;
// Only used in www builds.
export const enableSchedulerDebugging = false;
@@ -44,10 +44,8 @@ export function addUserTimingListener() {
// Disable javascript: URL strings in href for XSS protection.
export const disableJavaScriptURLs = false;
-// These APIs will no longer be "unstable" in the upcoming 16.7 release,
-// Control this behavior with a flag to support 16.6 minor releases in the meanwhile.
-export const exposeConcurrentModeAPIs = __EXPERIMENTAL__;
-
+// Warns when a combination of updates on a dom can cause a style declaration
+// that clashes with a previous one https://github.com/facebook/react/pull/14181
export const warnAboutShorthandPropertyCollision = true;
// Experimental React Flare event system and event components support.
@@ -84,20 +82,29 @@ export const warnAboutDefaultPropsOnFunctionComponents = false;
export const disableSchedulerTimeoutBasedOnReactExpirationTime = false;
-export const enableTrainModelFix = true;
-
export const enableTrustedTypesIntegration = false;
-// Flag to turn event.target and event.currentTarget in ReactNative from a reactTag to a component instance
-export const enableNativeTargetAsInstance = false;
+// Controls sequence of passive effect destroy and create functions.
+// If this flag is off, destroy and create functions may be interleaved.
+// When the flag is on, all destroy functions will be run (for all fibers)
+// before any create functions are run, similar to how layout effects work.
+// This flag provides a killswitch if that proves to break existing code somehow.
+export const runAllPassiveEffectDestroysBeforeCreates = false;
// Controls behavior of deferred effect destroy functions during unmount.
// Previously these functions were run during commit (along with layout effects).
// Ideally we should delay these until after commit for performance reasons.
// This flag provides a killswitch if that proves to break existing code somehow.
+//
+// WARNING This flag only has an affect if used with runAllPassiveEffectDestroysBeforeCreates.
export const deferPassiveEffectCleanupDuringUnmount = false;
-export const isTestEnvironment = false;
+// Enables a warning when trying to spread a 'key' to an element;
+// a deprecated pattern we want to get rid of in the future
+export const warnAboutSpreadingKeyToJSX = false;
+
+// Internal-only attempt to debug a React Native issue. See D20130868.
+export const throwEarlyForMysteriousError = false;
// --------------------------
// Future APIs to be deprecated
@@ -111,19 +118,14 @@ export const warnAboutStringRefs = false;
export const disableLegacyContext = false;
-// Disables React.createFactory
-export const disableCreateFactory = false;
-
// Disables children for