Skip to content

Commit

Permalink
Remove 'warning' module from the JS scheduler (facebook#13264)
Browse files Browse the repository at this point in the history
* Remove 'warning' module from the JS scheduler

**what is the change?:**
See title

**why make this change?:**
Internally the 'warning' module has some dependencies which we want to
avoid pulling in during the very early stages of initial pageload. It is
creating a cyclical dependency.

And we wanted to remove this dependency anyway, because this module
should be kept small and decoupled.

**test plan:**
- Tested the exact same change internally in Facebook.com
- Ran unit tests
- Tried out the fixture

**issue:**
Internal task T31831021

* check for console existence before calling console.error

* Move DEV check into separate block
  • Loading branch information
flarnie committed Jul 25, 2018
1 parent dbd16c8 commit 0154a79
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions packages/react-scheduler/src/ReactScheduler.js
Expand Up @@ -42,7 +42,6 @@ type CallbackConfigType = {|
export type CallbackIdType = CallbackConfigType;

import {canUseDOM} from 'shared/ExecutionEnvironment';
import warningWithoutStack from 'shared/warningWithoutStack';

// We capture a local reference to any global, in case it gets polyfilled after
// this module is initially evaluated.
Expand Down Expand Up @@ -123,21 +122,23 @@ if (!canUseDOM) {
localClearTimeout(timeoutId);
};
} else {
if (typeof localRequestAnimationFrame !== 'function') {
warningWithoutStack(
false,
"This browser doesn't support requestAnimationFrame. " +
'Make sure that you load a ' +
'polyfill in older browsers. https://fb.me/react-polyfills',
);
}
if (typeof localCancelAnimationFrame !== 'function') {
warningWithoutStack(
false,
"This browser doesn't support cancelAnimationFrame. " +
'Make sure that you load a ' +
'polyfill in older browsers. https://fb.me/react-polyfills',
);
if (__DEV__) {
if (typeof console !== 'undefined') {
if (typeof localRequestAnimationFrame !== 'function') {
console.error(
"This browser doesn't support requestAnimationFrame. " +
'Make sure that you load a ' +
'polyfill in older browsers. https://fb.me/react-polyfills',
);
}
if (typeof localCancelAnimationFrame !== 'function') {
console.error(
"This browser doesn't support cancelAnimationFrame. " +
'Make sure that you load a ' +
'polyfill in older browsers. https://fb.me/react-polyfills',
);
}
}
}

let headOfPendingCallbacksLinkedList: CallbackConfigType | null = null;
Expand Down

0 comments on commit 0154a79

Please sign in to comment.