Skip to content

Commit facce3d

Browse files
authored
Use Portals to test batching across roots (#8508)
This doesn't work by default in Fiber, you have to opt-in with a Portal to get the explicit ordering guarantees.
1 parent 48c7bbd commit facce3d

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

scripts/fiber/tests-failing.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ src/renderers/shared/shared/__tests__/ReactStatelessComponent-test.js
110110
* should warn when using non-React functions in JSX
111111

112112
src/renderers/shared/shared/__tests__/ReactUpdates-test.js
113-
* should queue mount-ready handlers across different roots
114113
* marks top-level updates
115114
* throws in setState if the update callback is not a function
116115
* throws in replaceState if the update callback is not a function

scripts/fiber/tests-passing.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1451,6 +1451,7 @@ src/renderers/shared/shared/__tests__/ReactUpdates-test.js
14511451
* should not reconcile children passed via props
14521452
* should flow updates correctly
14531453
* should share reconcile transaction across different roots
1454+
* should queue mount-ready handlers across different roots
14541455
* should flush updates in the correct order
14551456
* should flush updates in the correct order across roots
14561457
* should queue nested updates

src/renderers/shared/shared/__tests__/ReactUpdates-test.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,8 @@ describe('ReactUpdates', () => {
544544
// componentDidUpdate handlers is called, B's DOM should already have been
545545
// updated.
546546

547+
var bContainer = document.createElement('div');
548+
547549
var a;
548550
var b;
549551

@@ -558,7 +560,15 @@ describe('ReactUpdates', () => {
558560
}
559561

560562
render() {
561-
return <div>A{this.state.x}</div>;
563+
var portal = null;
564+
// If we're using Fiber, we use Portals instead to achieve this.
565+
if (ReactDOMFeatureFlags.useFiber) {
566+
portal = ReactDOM.unstable_createPortal(
567+
<B ref={n => b = n} />,
568+
bContainer
569+
);
570+
}
571+
return <div>A{this.state.x}{portal}</div>;
562572
}
563573
}
564574

@@ -571,7 +581,9 @@ describe('ReactUpdates', () => {
571581
}
572582

573583
a = ReactTestUtils.renderIntoDocument(<A />);
574-
b = ReactTestUtils.renderIntoDocument(<B />);
584+
if (!ReactDOMFeatureFlags.useFiber) {
585+
ReactDOM.render(<B ref={n => b = n} />, bContainer);
586+
}
575587

576588
ReactDOM.unstable_batchedUpdates(function() {
577589
a.setState({x: 1});

0 commit comments

Comments
 (0)