Skip to content

Commit 7c4ff13

Browse files
committed
Refactor Schedule, remove React-isms
Once the API stabilizes, we will move Schedule this into a separate repo. To promote adoption, especially by projects outside the React ecosystem, we'll remove all React-isms from the source and keep it as simple as possible: - No build step. - No static types. - Everything is in a single file. If we end up needing to support multiple targets, like CommonJS and ESM, we can still avoid a build step by maintaining two copies of the same file, but with different exports. This commit also refactors the implementation to split out the DOM- specific parts (essentially a requestIdleCallback polyfill). Aside from the architectural benefits, this also makes it possible to write host- agnostic tests. If/when we publish a version of Schedule that targets other environments, like React Native, we can run these same tests across all implementations.
1 parent 2282400 commit 7c4ff13

File tree

7 files changed

+520
-369
lines changed

7 files changed

+520
-369
lines changed

packages/react-dom/src/__tests__/ReactDOM-test.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,9 +455,11 @@ describe('ReactDOM', () => {
455455
try {
456456
delete global.requestAnimationFrame;
457457
jest.resetModules();
458-
expect(() => require('react-dom')).toWarnDev(
458+
spyOnDevAndProd(console, 'error');
459+
require('react-dom');
460+
expect(console.error.calls.count()).toEqual(1);
461+
expect(console.error.calls.argsFor(0)[0]).toMatch(
459462
"This browser doesn't support requestAnimationFrame.",
460-
{withoutStack: true},
461463
);
462464
} finally {
463465
global.requestAnimationFrame = previousRAF;

packages/react-reconciler/src/ReactFiberScheduler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ import {
153153
import {Dispatcher} from './ReactFiberDispatcher';
154154

155155
export type Deadline = {
156-
timeRemaining: () => number,
156+
timeRemaining(): number,
157157
didTimeout: boolean,
158158
};
159159

packages/schedule/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
*
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
6-
*
7-
* @flow
86
*/
97

108
'use strict';

0 commit comments

Comments
 (0)