Skip to content

Commit 8f64fb3

Browse files
committed
Remove usage of ReactDOMFeatureFlags.useFiber, assuming true
1 parent c076ca4 commit 8f64fb3

33 files changed

+2699
-3640
lines changed

src/isomorphic/children/__tests__/ReactChildren-test.js

Lines changed: 35 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
'use strict';
1313

14-
const ReactDOMFeatureFlags = require('ReactDOMFeatureFlags');
15-
1614
describe('ReactChildren', () => {
1715
var React;
1816
var ReactTestUtils;
@@ -880,52 +878,50 @@ describe('ReactChildren', () => {
880878
);
881879
});
882880

883-
if (ReactDOMFeatureFlags.useFiber) {
884-
describe('with fragments enabled', () => {
885-
it('warns for keys for arrays of elements in a fragment', () => {
886-
spyOn(console, 'error');
887-
class ComponentReturningArray extends React.Component {
888-
render() {
889-
return [<div />, <div />];
890-
}
881+
describe('with fragments enabled', () => {
882+
it('warns for keys for arrays of elements in a fragment', () => {
883+
spyOn(console, 'error');
884+
class ComponentReturningArray extends React.Component {
885+
render() {
886+
return [<div />, <div />];
891887
}
888+
}
892889

893-
ReactTestUtils.renderIntoDocument(<ComponentReturningArray />);
890+
ReactTestUtils.renderIntoDocument(<ComponentReturningArray />);
894891

895-
expectDev(console.error.calls.count()).toBe(1);
896-
expectDev(normalizeCodeLocInfo(console.error.calls.argsFor(0)[0])).toBe(
897-
'Warning: ' +
898-
'Each child in an array or iterator should have a unique "key" prop.' +
899-
' See https://fb.me/react-warning-keys for more information.' +
900-
'\n in ComponentReturningArray (at **)',
901-
);
902-
});
892+
expectDev(console.error.calls.count()).toBe(1);
893+
expectDev(normalizeCodeLocInfo(console.error.calls.argsFor(0)[0])).toBe(
894+
'Warning: ' +
895+
'Each child in an array or iterator should have a unique "key" prop.' +
896+
' See https://fb.me/react-warning-keys for more information.' +
897+
'\n in ComponentReturningArray (at **)',
898+
);
899+
});
903900

904-
it('does not warn when there are keys on elements in a fragment', () => {
905-
spyOn(console, 'error');
906-
class ComponentReturningArray extends React.Component {
907-
render() {
908-
return [<div key="foo" />, <div key="bar" />];
909-
}
901+
it('does not warn when there are keys on elements in a fragment', () => {
902+
spyOn(console, 'error');
903+
class ComponentReturningArray extends React.Component {
904+
render() {
905+
return [<div key="foo" />, <div key="bar" />];
910906
}
907+
}
911908

912-
ReactTestUtils.renderIntoDocument(<ComponentReturningArray />);
909+
ReactTestUtils.renderIntoDocument(<ComponentReturningArray />);
913910

914-
expectDev(console.error.calls.count()).toBe(0);
915-
});
911+
expectDev(console.error.calls.count()).toBe(0);
912+
});
916913

917-
it('warns for keys for arrays at the top level', () => {
918-
spyOn(console, 'error');
914+
it('warns for keys for arrays at the top level', () => {
915+
spyOn(console, 'error');
919916

920-
ReactTestUtils.renderIntoDocument([<div />, <div />]);
917+
ReactTestUtils.renderIntoDocument([<div />, <div />]);
921918

922-
expectDev(console.error.calls.count()).toBe(1);
923-
expectDev(normalizeCodeLocInfo(console.error.calls.argsFor(0)[0])).toBe(
924-
'Warning: ' +
925-
'Each child in an array or iterator should have a unique "key" prop.' +
926-
' See https://fb.me/react-warning-keys for more information.',
927-
);
928-
});
919+
expectDev(console.error.calls.count()).toBe(1);
920+
expectDev(normalizeCodeLocInfo(console.error.calls.argsFor(0)[0])).toBe(
921+
'Warning: ' +
922+
'Each child in an array or iterator should have a unique "key" prop.' +
923+
' See https://fb.me/react-warning-keys for more information.',
924+
);
929925
});
930-
}
926+
});
931927
});

src/isomorphic/classic/element/__tests__/ReactElement-test.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
var React;
1515
var ReactDOM;
1616
var ReactTestUtils;
17-
var ReactDOMFeatureFlags;
1817

1918
describe('ReactElement', () => {
2019
var ComponentClass;
@@ -31,7 +30,6 @@ describe('ReactElement', () => {
3130
React = require('react');
3231
ReactDOM = require('react-dom');
3332
ReactTestUtils = require('react-dom/test-utils');
34-
ReactDOMFeatureFlags = require('ReactDOMFeatureFlags');
3533
// NOTE: We're explicitly not using JSX here. This is intended to test
3634
// classic JS without JSX.
3735
ComponentClass = class extends React.Component {
@@ -237,12 +235,7 @@ describe('ReactElement', () => {
237235
var instance = ReactTestUtils.renderIntoDocument(
238236
React.createElement(Wrapper),
239237
);
240-
241-
if (ReactDOMFeatureFlags.useFiber) {
242-
expect(element._owner.stateNode).toBe(instance);
243-
} else {
244-
expect(element._owner.getPublicInstance()).toBe(instance);
245-
}
238+
expect(element._owner.stateNode).toBe(instance);
246239
});
247240

248241
it('merges an additional argument onto the children prop', () => {

src/renderers/__tests__/EventPluginHub-test.js

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,11 @@ jest.mock('isEventSupported');
1616
describe('EventPluginHub', () => {
1717
var React;
1818
var ReactTestUtils;
19-
var ReactDOMFeatureFlags;
2019

2120
beforeEach(() => {
2221
jest.resetModules();
2322
React = require('react');
2423
ReactTestUtils = require('react-dom/test-utils');
25-
ReactDOMFeatureFlags = require('ReactDOMFeatureFlags');
2624
});
2725

2826
it('should prevent non-function listeners, at dispatch', () => {
@@ -35,14 +33,10 @@ describe('EventPluginHub', () => {
3533
}).toThrowError(
3634
'Expected `onClick` listener to be a function, instead got a value of `string` type.',
3735
);
38-
if (ReactDOMFeatureFlags.useFiber) {
39-
expectDev(console.error.calls.count()).toBe(1);
40-
expectDev(console.error.calls.argsFor(0)[0]).toContain(
41-
'Expected `onClick` listener to be a function, instead got a value of `string` type.',
42-
);
43-
} else {
44-
expectDev(console.error.calls.count()).toBe(0);
45-
}
36+
expectDev(console.error.calls.count()).toBe(1);
37+
expectDev(console.error.calls.argsFor(0)[0]).toContain(
38+
'Expected `onClick` listener to be a function, instead got a value of `string` type.',
39+
);
4640
});
4741

4842
it('should not prevent null listeners, at dispatch', () => {

src/renderers/__tests__/ReactComponent-test.js

Lines changed: 71 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ var ReactDOM;
1616
var ReactDOMServer;
1717
var ReactTestUtils;
1818

19-
var ReactDOMFeatureFlags = require('ReactDOMFeatureFlags');
20-
2119
describe('ReactComponent', () => {
2220
function normalizeCodeLocInfo(str) {
2321
return str && str.replace(/\(at .+?:\d+\)/g, '(at **)');
@@ -299,21 +297,11 @@ describe('ReactComponent', () => {
299297
'outer componentDidMount',
300298
'start update',
301299
// Previous (equivalent) refs get cleared
302-
...(ReactDOMFeatureFlags.useFiber
303-
? [
304-
// Fiber renders first, resets refs later
305-
'inner 1 render',
306-
'inner 2 render',
307-
'ref 1 got null',
308-
'ref 2 got null',
309-
]
310-
: [
311-
// Stack resets refs before rendering
312-
'ref 1 got null',
313-
'inner 1 render',
314-
'ref 2 got null',
315-
'inner 2 render',
316-
]),
300+
// Fiber renders first, resets refs later
301+
'inner 1 render',
302+
'inner 2 render',
303+
'ref 1 got null',
304+
'ref 2 got null',
317305
'inner 1 componentDidUpdate',
318306
'ref 1 got instance 1',
319307
'inner 2 componentDidUpdate',
@@ -408,8 +396,7 @@ describe('ReactComponent', () => {
408396
'Objects are not valid as a React child (found: object with keys ' +
409397
'{x, y, z}). If you meant to render a collection of children, use ' +
410398
'an array instead.' +
411-
// Fiber gives a slightly better stack with the nearest host components
412-
(ReactDOMFeatureFlags.useFiber ? '\n in div (at **)' : ''),
399+
'\n in div (at **)',
413400
);
414401
});
415402

@@ -436,8 +423,7 @@ describe('ReactComponent', () => {
436423
'Objects are not valid as a React child (found: object with keys ' +
437424
'{a, b, c}). If you meant to render a collection of children, use ' +
438425
'an array instead.\n' +
439-
// Fiber gives a slightly better stack with the nearest host components
440-
(ReactDOMFeatureFlags.useFiber ? ' in div (at **)\n' : '') +
426+
' in div (at **)\n' +
441427
' in Foo (at **)',
442428
);
443429
});
@@ -460,8 +446,7 @@ describe('ReactComponent', () => {
460446
'Objects are not valid as a React child (found: object with keys ' +
461447
'{x, y, z}). If you meant to render a collection of children, use ' +
462448
'an array instead.' +
463-
// Fiber gives a slightly better stack with the nearest host components
464-
(ReactDOMFeatureFlags.useFiber ? '\n in div (at **)' : ''),
449+
'\n in div (at **)',
465450
);
466451
});
467452

@@ -488,79 +473,76 @@ describe('ReactComponent', () => {
488473
'Objects are not valid as a React child (found: object with keys ' +
489474
'{a, b, c}). If you meant to render a collection of children, use ' +
490475
'an array instead.\n' +
491-
// Fiber gives a slightly better stack with the nearest host components
492-
(ReactDOMFeatureFlags.useFiber ? ' in div (at **)\n' : '') +
476+
' in div (at **)\n' +
493477
' in Foo (at **)',
494478
);
495479
});
496480

497-
if (ReactDOMFeatureFlags.useFiber) {
498-
describe('with new features', () => {
499-
it('warns on function as a return value from a function', () => {
500-
function Foo() {
501-
return Foo;
502-
}
503-
spyOn(console, 'error');
504-
var container = document.createElement('div');
505-
ReactDOM.render(<Foo />, container);
506-
expectDev(console.error.calls.count()).toBe(1);
507-
expectDev(normalizeCodeLocInfo(console.error.calls.argsFor(0)[0])).toBe(
508-
'Warning: Functions are not valid as a React child. This may happen if ' +
509-
'you return a Component instead of <Component /> from render. ' +
510-
'Or maybe you meant to call this function rather than return it.\n' +
511-
' in Foo (at **)',
512-
);
513-
});
481+
describe('with new features', () => {
482+
it('warns on function as a return value from a function', () => {
483+
function Foo() {
484+
return Foo;
485+
}
486+
spyOn(console, 'error');
487+
var container = document.createElement('div');
488+
ReactDOM.render(<Foo />, container);
489+
expectDev(console.error.calls.count()).toBe(1);
490+
expectDev(normalizeCodeLocInfo(console.error.calls.argsFor(0)[0])).toBe(
491+
'Warning: Functions are not valid as a React child. This may happen if ' +
492+
'you return a Component instead of <Component /> from render. ' +
493+
'Or maybe you meant to call this function rather than return it.\n' +
494+
' in Foo (at **)',
495+
);
496+
});
514497

515-
it('warns on function as a return value from a class', () => {
516-
class Foo extends React.Component {
517-
render() {
518-
return Foo;
519-
}
498+
it('warns on function as a return value from a class', () => {
499+
class Foo extends React.Component {
500+
render() {
501+
return Foo;
520502
}
521-
spyOn(console, 'error');
522-
var container = document.createElement('div');
523-
ReactDOM.render(<Foo />, container);
524-
expectDev(console.error.calls.count()).toBe(1);
525-
expectDev(normalizeCodeLocInfo(console.error.calls.argsFor(0)[0])).toBe(
526-
'Warning: Functions are not valid as a React child. This may happen if ' +
527-
'you return a Component instead of <Component /> from render. ' +
528-
'Or maybe you meant to call this function rather than return it.\n' +
529-
' in Foo (at **)',
530-
);
531-
});
503+
}
504+
spyOn(console, 'error');
505+
var container = document.createElement('div');
506+
ReactDOM.render(<Foo />, container);
507+
expectDev(console.error.calls.count()).toBe(1);
508+
expectDev(normalizeCodeLocInfo(console.error.calls.argsFor(0)[0])).toBe(
509+
'Warning: Functions are not valid as a React child. This may happen if ' +
510+
'you return a Component instead of <Component /> from render. ' +
511+
'Or maybe you meant to call this function rather than return it.\n' +
512+
' in Foo (at **)',
513+
);
514+
});
532515

533-
it('warns on function as a child to host component', () => {
534-
function Foo() {
535-
return <div><span>{Foo}</span></div>;
536-
}
537-
spyOn(console, 'error');
538-
var container = document.createElement('div');
539-
ReactDOM.render(<Foo />, container);
540-
expectDev(console.error.calls.count()).toBe(1);
541-
expectDev(normalizeCodeLocInfo(console.error.calls.argsFor(0)[0])).toBe(
542-
'Warning: Functions are not valid as a React child. This may happen if ' +
543-
'you return a Component instead of <Component /> from render. ' +
544-
'Or maybe you meant to call this function rather than return it.\n' +
545-
' in span (at **)\n' +
546-
' in div (at **)\n' +
547-
' in Foo (at **)',
548-
);
549-
});
516+
it('warns on function as a child to host component', () => {
517+
function Foo() {
518+
return <div><span>{Foo}</span></div>;
519+
}
520+
spyOn(console, 'error');
521+
var container = document.createElement('div');
522+
ReactDOM.render(<Foo />, container);
523+
expectDev(console.error.calls.count()).toBe(1);
524+
expectDev(normalizeCodeLocInfo(console.error.calls.argsFor(0)[0])).toBe(
525+
'Warning: Functions are not valid as a React child. This may happen if ' +
526+
'you return a Component instead of <Component /> from render. ' +
527+
'Or maybe you meant to call this function rather than return it.\n' +
528+
' in span (at **)\n' +
529+
' in div (at **)\n' +
530+
' in Foo (at **)',
531+
);
532+
});
550533

551-
it('does not warn for function-as-a-child that gets resolved', () => {
552-
function Bar(props) {
553-
return props.children();
554-
}
555-
function Foo() {
556-
return <Bar>{() => 'Hello'}</Bar>;
557-
}
558-
spyOn(console, 'error');
559-
var container = document.createElement('div');
560-
ReactDOM.render(<Foo />, container);
561-
expect(container.innerHTML).toBe('Hello');
562-
expectDev(console.error.calls.count()).toBe(0);
563-
});
534+
it('does not warn for function-as-a-child that gets resolved', () => {
535+
function Bar(props) {
536+
return props.children();
537+
}
538+
function Foo() {
539+
return <Bar>{() => 'Hello'}</Bar>;
540+
}
541+
spyOn(console, 'error');
542+
var container = document.createElement('div');
543+
ReactDOM.render(<Foo />, container);
544+
expect(container.innerHTML).toBe('Hello');
545+
expectDev(console.error.calls.count()).toBe(0);
564546
});
565-
}
547+
});
566548
});

0 commit comments

Comments
 (0)