mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Remove disableNewFiberFeatures flag (#10585)
This commit is contained in:
@@ -16,7 +16,6 @@ const ReactDOMFeatureFlags = require('ReactDOMFeatureFlags');
|
||||
describe('ReactChildren', () => {
|
||||
var React;
|
||||
var ReactTestUtils;
|
||||
var ReactFeatureFlags;
|
||||
|
||||
function normalizeCodeLocInfo(str) {
|
||||
return str && str.replace(/at .+?:\d+/g, 'at **');
|
||||
@@ -883,11 +882,6 @@ describe('ReactChildren', () => {
|
||||
|
||||
if (ReactDOMFeatureFlags.useFiber) {
|
||||
describe('with fragments enabled', () => {
|
||||
beforeEach(() => {
|
||||
ReactFeatureFlags = require('ReactFeatureFlags');
|
||||
ReactFeatureFlags.disableNewFiberFeatures = false;
|
||||
});
|
||||
|
||||
it('warns for keys for arrays of elements in a fragment', () => {
|
||||
spyOn(console, 'error');
|
||||
class ComponentReturningArray extends React.Component {
|
||||
|
||||
@@ -496,10 +496,6 @@ describe('ReactComponent', () => {
|
||||
|
||||
if (ReactDOMFeatureFlags.useFiber) {
|
||||
describe('with new features', () => {
|
||||
beforeEach(() => {
|
||||
require('ReactFeatureFlags').disableNewFiberFeatures = false;
|
||||
});
|
||||
|
||||
it('warns on function as a return value from a function', () => {
|
||||
function Foo() {
|
||||
return Foo;
|
||||
|
||||
@@ -13,10 +13,11 @@
|
||||
|
||||
var React;
|
||||
var ReactDOM;
|
||||
var ReactDOMFeatureFlags;
|
||||
var ReactTestUtils;
|
||||
var TogglingComponent;
|
||||
|
||||
var ReactDOMFeatureFlags = require('ReactDOMFeatureFlags');
|
||||
|
||||
var log;
|
||||
|
||||
describe('ReactEmptyComponent', () => {
|
||||
@@ -25,7 +26,6 @@ describe('ReactEmptyComponent', () => {
|
||||
|
||||
React = require('react');
|
||||
ReactDOM = require('react-dom');
|
||||
ReactDOMFeatureFlags = require('ReactDOMFeatureFlags');
|
||||
ReactTestUtils = require('react-dom/test-utils');
|
||||
|
||||
log = jasmine.createSpy();
|
||||
@@ -71,18 +71,20 @@ describe('ReactEmptyComponent', () => {
|
||||
expect(container2.children.length).toBe(0);
|
||||
});
|
||||
|
||||
it('should still throw when rendering to undefined', () => {
|
||||
class Component extends React.Component {
|
||||
render() {}
|
||||
}
|
||||
if (ReactDOMFeatureFlags.useFiber) {
|
||||
it('should still throw when rendering to undefined', () => {
|
||||
class Component extends React.Component {
|
||||
render() {}
|
||||
}
|
||||
|
||||
expect(function() {
|
||||
ReactTestUtils.renderIntoDocument(<Component />);
|
||||
}).toThrowError(
|
||||
'Component.render(): A valid React element (or null) must be returned. You may ' +
|
||||
'have returned undefined, an array or some other invalid object.',
|
||||
);
|
||||
});
|
||||
expect(function() {
|
||||
ReactTestUtils.renderIntoDocument(<Component />);
|
||||
}).toThrowError(
|
||||
'Component(...): Nothing was returned from render. This usually means a return statement is missing. ' +
|
||||
'Or, to render nothing, return null.',
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
it('should be able to switch between rendering null and a normal tag', () => {
|
||||
var instance1 = (
|
||||
@@ -232,22 +234,15 @@ describe('ReactEmptyComponent', () => {
|
||||
});
|
||||
|
||||
it('can render null at the top level', () => {
|
||||
var ReactFeatureFlags = require('ReactFeatureFlags');
|
||||
ReactFeatureFlags.disableNewFiberFeatures = false;
|
||||
var div = document.createElement('div');
|
||||
|
||||
try {
|
||||
if (ReactDOMFeatureFlags.useFiber) {
|
||||
if (ReactDOMFeatureFlags.useFiber) {
|
||||
ReactDOM.render(null, div);
|
||||
expect(div.innerHTML).toBe('');
|
||||
} else {
|
||||
// Stack does not implement this.
|
||||
expect(function() {
|
||||
ReactDOM.render(null, div);
|
||||
expect(div.innerHTML).toBe('');
|
||||
} else {
|
||||
// Stack does not implement this.
|
||||
expect(function() {
|
||||
ReactDOM.render(null, div);
|
||||
}).toThrowError('ReactDOM.render(): Invalid component element.');
|
||||
}
|
||||
} finally {
|
||||
ReactFeatureFlags.disableNewFiberFeatures = true;
|
||||
}).toThrowError('ReactDOM.render(): Invalid component element.');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -157,15 +157,17 @@ describe('ReactStatelessComponent', () => {
|
||||
});
|
||||
}
|
||||
|
||||
it('should throw when stateless component returns undefined', () => {
|
||||
function NotAComponent() {}
|
||||
expect(function() {
|
||||
ReactTestUtils.renderIntoDocument(<div><NotAComponent /></div>);
|
||||
}).toThrowError(
|
||||
'NotAComponent(...): A valid React element (or null) must be returned. ' +
|
||||
'You may have returned undefined, an array or some other invalid object.',
|
||||
);
|
||||
});
|
||||
if (ReactDOMFeatureFlags.useFiber) {
|
||||
it('should throw when stateless component returns undefined', () => {
|
||||
function NotAComponent() {}
|
||||
expect(function() {
|
||||
ReactTestUtils.renderIntoDocument(<div><NotAComponent /></div>);
|
||||
}).toThrowError(
|
||||
'NotAComponent(...): Nothing was returned from render. ' +
|
||||
'This usually means a return statement is missing. Or, to render nothing, return null.',
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
it('should throw on string refs in pure functions', () => {
|
||||
function Child() {
|
||||
|
||||
@@ -394,11 +394,6 @@ describe('string refs between fiber and stack', () => {
|
||||
});
|
||||
|
||||
describe('root level refs', () => {
|
||||
beforeEach(() => {
|
||||
var ReactFeatureFlags = require('ReactFeatureFlags');
|
||||
ReactFeatureFlags.disableNewFiberFeatures = false;
|
||||
});
|
||||
|
||||
it('attaches and detaches root refs', () => {
|
||||
var ReactDOM = require('react-dom');
|
||||
var inst = null;
|
||||
|
||||
@@ -11,11 +11,7 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
var invariant = require('fbjs/lib/invariant');
|
||||
var React = require('react');
|
||||
var ReactPartialRenderer = require('ReactPartialRenderer');
|
||||
var ReactFeatureFlags = require('ReactFeatureFlags');
|
||||
|
||||
var Readable = require('stream').Readable;
|
||||
|
||||
// This is a Readable Node.js stream which wraps the ReactDOMPartialRenderer.
|
||||
@@ -41,13 +37,6 @@ class ReactMarkupReadableStream extends Readable {
|
||||
* See https://facebook.github.io/react/docs/react-dom-stream.html#rendertonodestream
|
||||
*/
|
||||
function renderToNodeStream(element) {
|
||||
const disableNewFiberFeatures = ReactFeatureFlags.disableNewFiberFeatures;
|
||||
if (disableNewFiberFeatures) {
|
||||
invariant(
|
||||
React.isValidElement(element),
|
||||
'renderToNodeStream(): Invalid component element.',
|
||||
);
|
||||
}
|
||||
return new ReactMarkupReadableStream(element, false);
|
||||
}
|
||||
|
||||
@@ -57,13 +46,6 @@ function renderToNodeStream(element) {
|
||||
* See https://facebook.github.io/react/docs/react-dom-stream.html#rendertostaticnodestream
|
||||
*/
|
||||
function renderToStaticNodeStream(element) {
|
||||
const disableNewFiberFeatures = ReactFeatureFlags.disableNewFiberFeatures;
|
||||
if (disableNewFiberFeatures) {
|
||||
invariant(
|
||||
React.isValidElement(element),
|
||||
'renderToStaticNodeStream(): Invalid component element.',
|
||||
);
|
||||
}
|
||||
return new ReactMarkupReadableStream(element, true);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,10 +11,7 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
var invariant = require('fbjs/lib/invariant');
|
||||
var React = require('react');
|
||||
var ReactPartialRenderer = require('ReactPartialRenderer');
|
||||
var ReactFeatureFlags = require('ReactFeatureFlags');
|
||||
|
||||
/**
|
||||
* Render a ReactElement to its initial HTML. This should only be used on the
|
||||
@@ -22,13 +19,6 @@ var ReactFeatureFlags = require('ReactFeatureFlags');
|
||||
* See https://facebook.github.io/react/docs/react-dom-server.html#rendertostring
|
||||
*/
|
||||
function renderToString(element) {
|
||||
const disableNewFiberFeatures = ReactFeatureFlags.disableNewFiberFeatures;
|
||||
if (disableNewFiberFeatures) {
|
||||
invariant(
|
||||
React.isValidElement(element),
|
||||
'renderToString(): Invalid component element.',
|
||||
);
|
||||
}
|
||||
var renderer = new ReactPartialRenderer(element, false);
|
||||
var markup = renderer.read(Infinity);
|
||||
return markup;
|
||||
@@ -40,13 +30,6 @@ function renderToString(element) {
|
||||
* See https://facebook.github.io/react/docs/react-dom-server.html#rendertostaticmarkup
|
||||
*/
|
||||
function renderToStaticMarkup(element) {
|
||||
const disableNewFiberFeatures = ReactFeatureFlags.disableNewFiberFeatures;
|
||||
if (disableNewFiberFeatures) {
|
||||
invariant(
|
||||
React.isValidElement(element),
|
||||
'renderToStaticMarkup(): Invalid component element.',
|
||||
);
|
||||
}
|
||||
var renderer = new ReactPartialRenderer(element, true);
|
||||
var markup = renderer.read(Infinity);
|
||||
return markup;
|
||||
|
||||
@@ -197,6 +197,7 @@ describe('ReactDOMProduction', () => {
|
||||
});
|
||||
|
||||
it('should throw with an error code in production', () => {
|
||||
const errorCode = ReactDOMFeatureFlags.useFiber ? 152 : 109;
|
||||
expect(function() {
|
||||
class Component extends React.Component {
|
||||
render() {
|
||||
@@ -207,8 +208,8 @@ describe('ReactDOMProduction', () => {
|
||||
var container = document.createElement('div');
|
||||
ReactDOM.render(<Component />, container);
|
||||
}).toThrowError(
|
||||
'Minified React error #109; visit ' +
|
||||
'http://facebook.github.io/react/docs/error-decoder.html?invariant=109&args[]=Component' +
|
||||
`Minified React error #${errorCode}; visit ` +
|
||||
`http://facebook.github.io/react/docs/error-decoder.html?invariant=${errorCode}&args[]=Component` +
|
||||
' for the full message or use the non-minified dev environment' +
|
||||
' for full errors and additional helpful warnings.',
|
||||
);
|
||||
|
||||
@@ -21,7 +21,6 @@ var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
|
||||
var ReactBrowserEventEmitter = require('ReactBrowserEventEmitter');
|
||||
var ReactControlledComponent = require('ReactControlledComponent');
|
||||
var ReactDOMComponentTree = require('ReactDOMComponentTree');
|
||||
var ReactFeatureFlags = require('ReactFeatureFlags');
|
||||
var ReactDOMFeatureFlags = require('ReactDOMFeatureFlags');
|
||||
var ReactDOMFiberComponent = require('ReactDOMFiberComponent');
|
||||
var ReactDOMFrameScheduling = require('ReactDOMFrameScheduling');
|
||||
@@ -31,7 +30,6 @@ var ReactInputSelection = require('ReactInputSelection');
|
||||
var ReactInstanceMap = require('ReactInstanceMap');
|
||||
var ReactPortal = require('ReactPortal');
|
||||
var ReactVersion = require('ReactVersion');
|
||||
var {isValidElement} = require('react');
|
||||
var {injectInternals} = require('ReactFiberDevToolsHook');
|
||||
var {
|
||||
ELEMENT_NODE,
|
||||
@@ -659,38 +657,6 @@ var ReactDOMFiber = {
|
||||
container: DOMContainer,
|
||||
callback: ?Function,
|
||||
) {
|
||||
if (ReactFeatureFlags.disableNewFiberFeatures) {
|
||||
// Top-level check occurs here instead of inside child reconciler
|
||||
// because requirements vary between renderers. E.g. React Art
|
||||
// allows arrays.
|
||||
if (!isValidElement(element)) {
|
||||
if (typeof element === 'string') {
|
||||
invariant(
|
||||
false,
|
||||
'ReactDOM.render(): Invalid component element. Instead of ' +
|
||||
"passing a string like 'div', pass " +
|
||||
"React.createElement('div') or <div />.",
|
||||
);
|
||||
} else if (typeof element === 'function') {
|
||||
invariant(
|
||||
false,
|
||||
'ReactDOM.render(): Invalid component element. Instead of ' +
|
||||
'passing a class like Foo, pass React.createElement(Foo) ' +
|
||||
'or <Foo />.',
|
||||
);
|
||||
} else if (element != null && typeof element.props !== 'undefined') {
|
||||
// Check if it quacks like an element
|
||||
invariant(
|
||||
false,
|
||||
'ReactDOM.render(): Invalid component element. This may be ' +
|
||||
'caused by unintentionally loading two independent copies ' +
|
||||
'of React.',
|
||||
);
|
||||
} else {
|
||||
invariant(false, 'ReactDOM.render(): Invalid component element.');
|
||||
}
|
||||
}
|
||||
}
|
||||
return renderSubtreeIntoContainer(
|
||||
null,
|
||||
element,
|
||||
|
||||
@@ -23,17 +23,9 @@ describe('ReactDOMFiber', () => {
|
||||
}
|
||||
|
||||
var container;
|
||||
var ReactFeatureFlags;
|
||||
|
||||
beforeEach(() => {
|
||||
container = document.createElement('div');
|
||||
ReactFeatureFlags = require('ReactFeatureFlags');
|
||||
ReactFeatureFlags.disableNewFiberFeatures = false;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
ReactFeatureFlags = require('ReactFeatureFlags');
|
||||
ReactFeatureFlags.disableNewFiberFeatures = true;
|
||||
});
|
||||
|
||||
it('should render strings as children', () => {
|
||||
@@ -1103,68 +1095,3 @@ describe('ReactDOMFiber', () => {
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// disableNewFiberFeatures currently defaults to true in test
|
||||
describe('disableNewFiberFeatures', () => {
|
||||
var container;
|
||||
var ReactFeatureFlags;
|
||||
|
||||
beforeEach(() => {
|
||||
container = document.createElement('div');
|
||||
ReactFeatureFlags = require('ReactFeatureFlags');
|
||||
ReactFeatureFlags.disableNewFiberFeatures = true;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
ReactFeatureFlags = require('ReactFeatureFlags');
|
||||
ReactFeatureFlags.disableNewFiberFeatures = false;
|
||||
});
|
||||
|
||||
it('throws if non-element passed to top-level render', () => {
|
||||
const message = 'render(): Invalid component element.';
|
||||
expect(() => ReactDOM.render(null, container)).toThrow(message, container);
|
||||
expect(() => ReactDOM.render(undefined, container)).toThrow(
|
||||
message,
|
||||
container,
|
||||
);
|
||||
expect(() => ReactDOM.render(false, container)).toThrow(message, container);
|
||||
expect(() => ReactDOM.render('Hi', container)).toThrow(message, container);
|
||||
expect(() => ReactDOM.render(999, container)).toThrow(message, container);
|
||||
expect(() => ReactDOM.render([<div key="a" />], container)).toThrow(
|
||||
message,
|
||||
container,
|
||||
);
|
||||
});
|
||||
|
||||
it('throws if something other than false, null, or an element is returned from render', () => {
|
||||
function Render(props) {
|
||||
return props.children;
|
||||
}
|
||||
|
||||
expect(() => ReactDOM.render(<Render>Hi</Render>, container)).toThrow(
|
||||
/You may have returned undefined/,
|
||||
);
|
||||
expect(() => ReactDOM.render(<Render>{999}</Render>, container)).toThrow(
|
||||
/You may have returned undefined/,
|
||||
);
|
||||
expect(() =>
|
||||
ReactDOM.render(<Render>[<div key="a" />]</Render>, container),
|
||||
).toThrow(/You may have returned undefined/);
|
||||
});
|
||||
|
||||
it('treats mocked render functions as if they return null', () => {
|
||||
class Mocked extends React.Component {}
|
||||
Mocked.prototype.render = jest.fn();
|
||||
ReactDOM.render(<Mocked />, container);
|
||||
expect(container.textContent).toEqual('');
|
||||
});
|
||||
|
||||
it('throws if the React package cannot be loaded', () => {
|
||||
jest.resetModules();
|
||||
jest.mock('react', () => undefined);
|
||||
expect(() => require('react-dom')).toThrow(
|
||||
'ReactDOM was loaded before React.',
|
||||
);
|
||||
jest.resetModules();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -323,7 +323,6 @@ function resetModules() {
|
||||
// TODO: can we express this test with only public API?
|
||||
ExecutionEnvironment = require('ExecutionEnvironment');
|
||||
|
||||
require('ReactFeatureFlags').disableNewFiberFeatures = false;
|
||||
PropTypes = require('prop-types');
|
||||
React = require('react');
|
||||
ReactDOM = require('react-dom');
|
||||
@@ -334,7 +333,6 @@ function resetModules() {
|
||||
// Resetting is important because we want to avoid any shared state
|
||||
// influencing the tests.
|
||||
jest.resetModuleRegistry();
|
||||
require('ReactFeatureFlags').disableNewFiberFeatures = false;
|
||||
ReactDOMServer = require('react-dom/server');
|
||||
}
|
||||
|
||||
|
||||
@@ -68,29 +68,24 @@ describe('ReactMount', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('throws when given a string', () => {
|
||||
expect(function() {
|
||||
ReactTestUtils.renderIntoDocument('div');
|
||||
}).toThrowError(
|
||||
'ReactDOM.render(): Invalid component element. Instead of passing a ' +
|
||||
"string like 'div', pass React.createElement('div') or <div />.",
|
||||
);
|
||||
});
|
||||
|
||||
it('throws when given a factory', () => {
|
||||
class Component extends React.Component {
|
||||
render() {
|
||||
return <div />;
|
||||
if (ReactDOMFeatureFlags.useFiber) {
|
||||
it('warns when given a factory', () => {
|
||||
spyOn(console, 'error');
|
||||
class Component extends React.Component {
|
||||
render() {
|
||||
return <div />;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
expect(function() {
|
||||
ReactTestUtils.renderIntoDocument(Component);
|
||||
}).toThrowError(
|
||||
'ReactDOM.render(): Invalid component element. Instead of passing a ' +
|
||||
'class like Foo, pass React.createElement(Foo) or <Foo />.',
|
||||
);
|
||||
});
|
||||
expectDev(console.error.calls.count()).toBe(1);
|
||||
expectDev(console.error.calls.argsFor(0)[0]).toContain(
|
||||
'Functions are not valid as a React child. ' +
|
||||
'This may happen if you return a Component instead of <Component /> from render. ' +
|
||||
'Or maybe you meant to call this function rather than return it.',
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
it('should render different components in same root', () => {
|
||||
var container = document.createElement('container');
|
||||
@@ -401,9 +396,6 @@ describe('ReactMount', () => {
|
||||
let mountPoint;
|
||||
|
||||
beforeEach(() => {
|
||||
const ReactFeatureFlags = require('ReactFeatureFlags');
|
||||
ReactFeatureFlags.disableNewFiberFeatures = false;
|
||||
|
||||
containerDiv = document.createElement('div');
|
||||
containerDiv.innerHTML = 'A<!-- react-mount-point-unstable -->B';
|
||||
mountPoint = containerDiv.childNodes[1];
|
||||
|
||||
@@ -19,7 +19,6 @@ var ReactMarkupChecksum;
|
||||
var ReactReconcileTransaction;
|
||||
var ReactTestUtils;
|
||||
var PropTypes;
|
||||
var ReactFeatureFlags;
|
||||
|
||||
var ReactDOMFeatureFlags = require('ReactDOMFeatureFlags');
|
||||
|
||||
@@ -36,9 +35,6 @@ describe('ReactDOMServer', () => {
|
||||
ReactReconcileTransaction = require('ReactReconcileTransaction');
|
||||
PropTypes = require('prop-types');
|
||||
|
||||
ReactFeatureFlags = require('ReactFeatureFlags');
|
||||
ReactFeatureFlags.disableNewFiberFeatures = false;
|
||||
|
||||
ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
|
||||
ExecutionEnvironment.canUseDOM = false;
|
||||
ReactDOMServer = require('react-dom/server');
|
||||
|
||||
@@ -27,7 +27,6 @@ var ReactTypeOfWork = require('ReactTypeOfWork');
|
||||
|
||||
var emptyObject = require('fbjs/lib/emptyObject');
|
||||
var invariant = require('fbjs/lib/invariant');
|
||||
var ReactFeatureFlags = require('ReactFeatureFlags');
|
||||
|
||||
if (__DEV__) {
|
||||
var {getCurrentFiberStackAddendum} = require('ReactDebugCurrentFiber');
|
||||
@@ -576,8 +575,7 @@ function ChildReconciler(shouldClone, shouldTrackSideEffects) {
|
||||
}
|
||||
|
||||
if (__DEV__) {
|
||||
const disableNewFiberFeatures = ReactFeatureFlags.disableNewFiberFeatures;
|
||||
if (!disableNewFiberFeatures && typeof newChild === 'function') {
|
||||
if (typeof newChild === 'function') {
|
||||
warnOnFunctionType();
|
||||
}
|
||||
}
|
||||
@@ -656,8 +654,7 @@ function ChildReconciler(shouldClone, shouldTrackSideEffects) {
|
||||
}
|
||||
|
||||
if (__DEV__) {
|
||||
const disableNewFiberFeatures = ReactFeatureFlags.disableNewFiberFeatures;
|
||||
if (!disableNewFiberFeatures && typeof newChild === 'function') {
|
||||
if (typeof newChild === 'function') {
|
||||
warnOnFunctionType();
|
||||
}
|
||||
}
|
||||
@@ -722,8 +719,7 @@ function ChildReconciler(shouldClone, shouldTrackSideEffects) {
|
||||
}
|
||||
|
||||
if (__DEV__) {
|
||||
const disableNewFiberFeatures = ReactFeatureFlags.disableNewFiberFeatures;
|
||||
if (!disableNewFiberFeatures && typeof newChild === 'function') {
|
||||
if (typeof newChild === 'function') {
|
||||
warnOnFunctionType();
|
||||
}
|
||||
}
|
||||
@@ -1301,118 +1297,51 @@ function ChildReconciler(shouldClone, shouldTrackSideEffects) {
|
||||
// not as a fragment. Nested arrays on the other hand will be treated as
|
||||
// fragment nodes. Recursion happens at the normal flow.
|
||||
|
||||
const disableNewFiberFeatures = ReactFeatureFlags.disableNewFiberFeatures;
|
||||
|
||||
// Handle object types
|
||||
const isObject = typeof newChild === 'object' && newChild !== null;
|
||||
if (isObject) {
|
||||
// Support only the subset of return types that Stack supports. Treat
|
||||
// everything else as empty, but log a warning.
|
||||
if (disableNewFiberFeatures) {
|
||||
switch (newChild.$$typeof) {
|
||||
case REACT_ELEMENT_TYPE:
|
||||
return placeSingleChild(
|
||||
reconcileSingleElement(
|
||||
returnFiber,
|
||||
currentFirstChild,
|
||||
newChild,
|
||||
priority,
|
||||
),
|
||||
);
|
||||
|
||||
case REACT_PORTAL_TYPE:
|
||||
return placeSingleChild(
|
||||
reconcileSinglePortal(
|
||||
returnFiber,
|
||||
currentFirstChild,
|
||||
newChild,
|
||||
priority,
|
||||
),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
switch (newChild.$$typeof) {
|
||||
case REACT_ELEMENT_TYPE:
|
||||
return placeSingleChild(
|
||||
reconcileSingleElement(
|
||||
returnFiber,
|
||||
currentFirstChild,
|
||||
newChild,
|
||||
priority,
|
||||
),
|
||||
);
|
||||
|
||||
case REACT_COROUTINE_TYPE:
|
||||
return placeSingleChild(
|
||||
reconcileSingleCoroutine(
|
||||
returnFiber,
|
||||
currentFirstChild,
|
||||
newChild,
|
||||
priority,
|
||||
),
|
||||
);
|
||||
|
||||
case REACT_YIELD_TYPE:
|
||||
return placeSingleChild(
|
||||
reconcileSingleYield(
|
||||
returnFiber,
|
||||
currentFirstChild,
|
||||
newChild,
|
||||
priority,
|
||||
),
|
||||
);
|
||||
|
||||
case REACT_PORTAL_TYPE:
|
||||
return placeSingleChild(
|
||||
reconcileSinglePortal(
|
||||
returnFiber,
|
||||
currentFirstChild,
|
||||
newChild,
|
||||
priority,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (disableNewFiberFeatures) {
|
||||
// The new child is not an element. If it's not null or false,
|
||||
// and the return fiber is a composite component, throw an error.
|
||||
switch (returnFiber.tag) {
|
||||
case ClassComponent: {
|
||||
if (__DEV__) {
|
||||
const instance = returnFiber.stateNode;
|
||||
if (
|
||||
instance.render._isMockFunction &&
|
||||
typeof newChild === 'undefined'
|
||||
) {
|
||||
// We allow auto-mocks to proceed as if they're
|
||||
// returning null.
|
||||
break;
|
||||
}
|
||||
}
|
||||
const Component = returnFiber.type;
|
||||
invariant(
|
||||
newChild === null || newChild === false,
|
||||
'%s.render(): A valid React element (or null) must be returned. ' +
|
||||
'You may have returned undefined, an array or some other ' +
|
||||
'invalid object.',
|
||||
Component.displayName || Component.name || 'Component',
|
||||
switch (newChild.$$typeof) {
|
||||
case REACT_ELEMENT_TYPE:
|
||||
return placeSingleChild(
|
||||
reconcileSingleElement(
|
||||
returnFiber,
|
||||
currentFirstChild,
|
||||
newChild,
|
||||
priority,
|
||||
),
|
||||
);
|
||||
break;
|
||||
}
|
||||
case FunctionalComponent: {
|
||||
// Composites accept elements, portals, null, or false
|
||||
const Component = returnFiber.type;
|
||||
invariant(
|
||||
newChild === null || newChild === false,
|
||||
'%s(...): A valid React element (or null) must be returned. ' +
|
||||
'You may have returned undefined, an array or some other ' +
|
||||
'invalid object.',
|
||||
Component.displayName || Component.name || 'Component',
|
||||
|
||||
case REACT_COROUTINE_TYPE:
|
||||
return placeSingleChild(
|
||||
reconcileSingleCoroutine(
|
||||
returnFiber,
|
||||
currentFirstChild,
|
||||
newChild,
|
||||
priority,
|
||||
),
|
||||
);
|
||||
|
||||
case REACT_YIELD_TYPE:
|
||||
return placeSingleChild(
|
||||
reconcileSingleYield(
|
||||
returnFiber,
|
||||
currentFirstChild,
|
||||
newChild,
|
||||
priority,
|
||||
),
|
||||
);
|
||||
|
||||
case REACT_PORTAL_TYPE:
|
||||
return placeSingleChild(
|
||||
reconcileSinglePortal(
|
||||
returnFiber,
|
||||
currentFirstChild,
|
||||
newChild,
|
||||
priority,
|
||||
),
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1450,11 +1379,11 @@ function ChildReconciler(shouldClone, shouldTrackSideEffects) {
|
||||
}
|
||||
|
||||
if (__DEV__) {
|
||||
if (!disableNewFiberFeatures && typeof newChild === 'function') {
|
||||
if (typeof newChild === 'function') {
|
||||
warnOnFunctionType();
|
||||
}
|
||||
}
|
||||
if (!disableNewFiberFeatures && typeof newChild === 'undefined') {
|
||||
if (typeof newChild === 'undefined') {
|
||||
// If the new child is undefined, and the return fiber is a composite
|
||||
// component, throw an error. If Fiber return types are disabled,
|
||||
// we already threw above.
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
var React;
|
||||
var ReactNoop;
|
||||
var ReactCoroutine;
|
||||
var ReactFeatureFlags;
|
||||
|
||||
describe('ReactCoroutine', () => {
|
||||
beforeEach(() => {
|
||||
@@ -23,8 +22,6 @@ describe('ReactCoroutine', () => {
|
||||
ReactNoop = require('react-noop-renderer');
|
||||
// TODO: can we express this test with only public API?
|
||||
ReactCoroutine = require('ReactCoroutine');
|
||||
ReactFeatureFlags = require('ReactFeatureFlags');
|
||||
ReactFeatureFlags.disableNewFiberFeatures = false;
|
||||
});
|
||||
|
||||
function div(...children) {
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
|
||||
var React;
|
||||
var ReactNoop;
|
||||
var ReactFeatureFlags;
|
||||
var PropTypes;
|
||||
|
||||
describe('ReactIncremental', () => {
|
||||
@@ -22,9 +21,6 @@ describe('ReactIncremental', () => {
|
||||
React = require('react');
|
||||
ReactNoop = require('react-noop-renderer');
|
||||
PropTypes = require('prop-types');
|
||||
|
||||
ReactFeatureFlags = require('ReactFeatureFlags');
|
||||
ReactFeatureFlags.disableNewFiberFeatures = false;
|
||||
});
|
||||
|
||||
it('should render a simple component', () => {
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
var PropTypes;
|
||||
var React;
|
||||
var ReactNoop;
|
||||
var ReactFeatureFlags;
|
||||
|
||||
describe('ReactIncrementalErrorHandling', () => {
|
||||
beforeEach(() => {
|
||||
@@ -22,8 +21,6 @@ describe('ReactIncrementalErrorHandling', () => {
|
||||
PropTypes = require('prop-types');
|
||||
React = require('react');
|
||||
ReactNoop = require('react-noop-renderer');
|
||||
ReactFeatureFlags = require('ReactFeatureFlags');
|
||||
ReactFeatureFlags.disableNewFiberFeatures = false;
|
||||
});
|
||||
|
||||
function div(...children) {
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
describe('ReactDebugFiberPerf', () => {
|
||||
let React;
|
||||
let ReactCoroutine;
|
||||
let ReactFeatureFlags;
|
||||
let ReactNoop;
|
||||
let ReactPortal;
|
||||
let PropTypes;
|
||||
@@ -121,8 +120,6 @@ describe('ReactDebugFiberPerf', () => {
|
||||
// TODO: can we express this test with only public API?
|
||||
ReactCoroutine = require('ReactCoroutine');
|
||||
ReactPortal = require('ReactPortal');
|
||||
ReactFeatureFlags = require('ReactFeatureFlags');
|
||||
ReactFeatureFlags.disableNewFiberFeatures = false;
|
||||
PropTypes = require('prop-types');
|
||||
});
|
||||
|
||||
|
||||
@@ -13,15 +13,12 @@
|
||||
|
||||
var React;
|
||||
var ReactNoop;
|
||||
var ReactFeatureFlags;
|
||||
|
||||
describe('ReactIncrementalReflection', () => {
|
||||
beforeEach(() => {
|
||||
jest.resetModules();
|
||||
React = require('react');
|
||||
ReactNoop = require('react-noop-renderer');
|
||||
ReactFeatureFlags = require('ReactFeatureFlags');
|
||||
ReactFeatureFlags.disableNewFiberFeatures = false;
|
||||
});
|
||||
|
||||
it('handles isMounted even when the initial render is deferred', () => {
|
||||
|
||||
@@ -13,15 +13,12 @@
|
||||
|
||||
var React;
|
||||
var ReactNoop;
|
||||
var ReactFeatureFlags;
|
||||
|
||||
describe('ReactIncrementalScheduling', () => {
|
||||
beforeEach(() => {
|
||||
jest.resetModules();
|
||||
React = require('react');
|
||||
ReactNoop = require('react-noop-renderer');
|
||||
ReactFeatureFlags = require('ReactFeatureFlags');
|
||||
ReactFeatureFlags.disableNewFiberFeatures = false;
|
||||
});
|
||||
|
||||
function span(prop) {
|
||||
|
||||
@@ -13,15 +13,12 @@
|
||||
|
||||
var React;
|
||||
var ReactNoop;
|
||||
var ReactFeatureFlags;
|
||||
|
||||
describe('ReactIncrementalSideEffects', () => {
|
||||
beforeEach(() => {
|
||||
jest.resetModules();
|
||||
React = require('react');
|
||||
ReactNoop = require('react-noop-renderer');
|
||||
ReactFeatureFlags = require('ReactFeatureFlags');
|
||||
ReactFeatureFlags.disableNewFiberFeatures = false;
|
||||
});
|
||||
|
||||
function normalizeCodeLocInfo(str) {
|
||||
|
||||
@@ -13,16 +13,12 @@
|
||||
|
||||
var React;
|
||||
var ReactNoop;
|
||||
var ReactFeatureFlags;
|
||||
|
||||
describe('ReactIncrementalTriangle', () => {
|
||||
beforeEach(() => {
|
||||
jest.resetModules();
|
||||
React = require('react');
|
||||
ReactNoop = require('ReactNoopEntry');
|
||||
|
||||
ReactFeatureFlags = require('ReactFeatureFlags');
|
||||
ReactFeatureFlags.disableNewFiberFeatures = false;
|
||||
});
|
||||
|
||||
function span(prop) {
|
||||
|
||||
@@ -13,15 +13,12 @@
|
||||
|
||||
var React;
|
||||
var ReactNoop;
|
||||
var ReactFeatureFlags;
|
||||
|
||||
describe('ReactIncrementalUpdates', () => {
|
||||
beforeEach(() => {
|
||||
jest.resetModuleRegistry();
|
||||
React = require('react');
|
||||
ReactNoop = require('react-noop-renderer');
|
||||
ReactFeatureFlags = require('ReactFeatureFlags');
|
||||
ReactFeatureFlags.disableNewFiberFeatures = false;
|
||||
});
|
||||
|
||||
function span(prop) {
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
|
||||
var React;
|
||||
var ReactNoop;
|
||||
var ReactFeatureFlags;
|
||||
|
||||
// This is a new feature in Fiber so I put it in its own test file. It could
|
||||
// probably move to one of the other test files once it is official.
|
||||
@@ -22,8 +21,6 @@ describe('ReactTopLevelFragment', function() {
|
||||
jest.resetModules();
|
||||
React = require('react');
|
||||
ReactNoop = require('react-noop-renderer');
|
||||
ReactFeatureFlags = require('ReactFeatureFlags');
|
||||
ReactFeatureFlags.disableNewFiberFeatures = false;
|
||||
});
|
||||
|
||||
it('should render a simple fragment at the top of a component', function() {
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
|
||||
var React;
|
||||
var ReactNoop;
|
||||
var ReactFeatureFlags;
|
||||
|
||||
// This is a new feature in Fiber so I put it in its own test file. It could
|
||||
// probably move to one of the other test files once it is official.
|
||||
@@ -22,8 +21,6 @@ describe('ReactTopLevelText', () => {
|
||||
jest.resetModules();
|
||||
React = require('react');
|
||||
ReactNoop = require('react-noop-renderer');
|
||||
ReactFeatureFlags = require('ReactFeatureFlags');
|
||||
ReactFeatureFlags.disableNewFiberFeatures = false;
|
||||
});
|
||||
|
||||
it('should render a component returning strings directly from render', () => {
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
'use strict';
|
||||
|
||||
var ReactFeatureFlags = {
|
||||
disableNewFiberFeatures: false,
|
||||
enableAsyncSubtreeAPI: true,
|
||||
};
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
var React = require('react');
|
||||
var ReactTestRenderer = require('react-test-renderer');
|
||||
var prettyFormat = require('pretty-format');
|
||||
var ReactFeatureFlags;
|
||||
|
||||
// Kind of hacky, but we nullify all the instances to test the tree structure
|
||||
// with jasmine's deep equality function, and test the instances separate. We
|
||||
@@ -40,11 +39,6 @@ function cleanNode(node) {
|
||||
}
|
||||
|
||||
describe('ReactTestRenderer', () => {
|
||||
beforeEach(() => {
|
||||
ReactFeatureFlags = require('ReactFeatureFlags');
|
||||
ReactFeatureFlags.disableNewFiberFeatures = false;
|
||||
});
|
||||
|
||||
function normalizeCodeLocInfo(str) {
|
||||
return str && str.replace(/\(at .+?:\d+\)/g, '(at **)');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user