Skip to content

Commit

Permalink
Replace old Fiber Scheduler with new one (#15387)
Browse files Browse the repository at this point in the history
The new Fiber Scheduler has been running in Facebook for several days
without issues. Let's switch to it.
  • Loading branch information
acdlite committed Apr 12, 2019
1 parent 4e59d4f commit 9055e31
Show file tree
Hide file tree
Showing 34 changed files with 2,917 additions and 7,085 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@
"test": "cross-env NODE_ENV=development jest --config ./scripts/jest/config.source.js",
"test-persistent": "cross-env NODE_ENV=development jest --config ./scripts/jest/config.source-persistent.js",
"test-fire": "cross-env NODE_ENV=development jest --config ./scripts/jest/config.source-fire.js",
"test-new-scheduler": "cross-env NODE_ENV=development jest --config ./scripts/jest/config.source-new-scheduler.js",
"test-prod": "cross-env NODE_ENV=production jest --config ./scripts/jest/config.source.js",
"test-fire-prod": "cross-env NODE_ENV=production jest --config ./scripts/jest/config.source-fire.js",
"test-prod-build": "yarn test-build-prod",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@

'use strict';

let ReactFeatureFlags;
let enableNewScheduler;
let React;
let ReactDOM;
let Scheduler;
Expand All @@ -21,8 +19,6 @@ describe('ReactDOMHooks', () => {
beforeEach(() => {
jest.resetModules();

ReactFeatureFlags = require('shared/ReactFeatureFlags');
enableNewScheduler = ReactFeatureFlags.enableNewScheduler;
React = require('react');
ReactDOM = require('react-dom');
Scheduler = require('scheduler');
Expand Down Expand Up @@ -101,30 +97,15 @@ describe('ReactDOMHooks', () => {
}

ReactDOM.render(<Foo />, container);

if (enableNewScheduler) {
// The old behavior was accidental; in the new scheduler, flushing passive
// effects also flushes synchronous work, even inside batchedUpdates.
ReactDOM.unstable_batchedUpdates(() => {
_set(0); // Forces the effect to be flushed
expect(otherContainer.textContent).toBe('A');
ReactDOM.render(<B />, otherContainer);
expect(otherContainer.textContent).toBe('A');
});
expect(otherContainer.textContent).toBe('B');
expect(calledA).toBe(true);
expect(calledB).toBe(true);
} else {
ReactDOM.unstable_batchedUpdates(() => {
_set(0); // Forces the effect to be flushed
expect(otherContainer.textContent).toBe('');
ReactDOM.render(<B />, otherContainer);
expect(otherContainer.textContent).toBe('');
});
expect(otherContainer.textContent).toBe('B');
expect(calledA).toBe(false); // It was in a batch
expect(calledB).toBe(true);
}
ReactDOM.unstable_batchedUpdates(() => {
_set(0); // Forces the effect to be flushed
expect(otherContainer.textContent).toBe('A');
ReactDOM.render(<B />, otherContainer);
expect(otherContainer.textContent).toBe('A');
});
expect(otherContainer.textContent).toBe('B');
expect(calledA).toBe(true);
expect(calledB).toBe(true);
});

it('should not bail out when an update is scheduled from within an event handler', () => {
Expand Down
14 changes: 0 additions & 14 deletions packages/react-dom/unstable-new-scheduler.fb.js

This file was deleted.

16 changes: 0 additions & 16 deletions packages/react-dom/unstable-new-scheduler.js

This file was deleted.

265 changes: 0 additions & 265 deletions packages/react-reconciler/src/ReactFiberPendingPriority.js

This file was deleted.

Loading

0 comments on commit 9055e31

Please sign in to comment.