@samitouri / QOS-React / commits / 0154a79fed

Remove 'warning' module from the JS scheduler (#13264)

* 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

Flarnie Marchan committed Jul 25, 2018 at 08:58 UTC 0154a79fedef38a824a837c535bc853013dd4588
1 file changed +17 -16
packages/react-scheduler/src/ReactScheduler.js
+17 -16
@@ -42,7 +42,6 @@ type CallbackConfigType = {|
42 export type CallbackIdType = CallbackConfigType;
43
44 import {canUseDOM} from 'shared/ExecutionEnvironment';
45 -import warningWithoutStack from 'shared/warningWithoutStack';
45
46 // We capture a local reference to any global, in case it gets polyfilled after
47 // this module is initially evaluated.
@@ -123,21 +122,23 @@ if (!canUseDOM) {
122 localClearTimeout(timeoutId);
123 };
124 } else {
126 - if (typeof localRequestAnimationFrame !== 'function') {
127 - warningWithoutStack(
128 - false,
129 - "This browser doesn't support requestAnimationFrame. " +
130 - 'Make sure that you load a ' +
131 - 'polyfill in older browsers. https://fb.me/react-polyfills',
132 - );
133 - }
134 - if (typeof localCancelAnimationFrame !== 'function') {
135 - warningWithoutStack(
136 - false,
137 - "This browser doesn't support cancelAnimationFrame. " +
138 - 'Make sure that you load a ' +
139 - 'polyfill in older browsers. https://fb.me/react-polyfills',
140 - );
125 + if (__DEV__) {
126 + if (typeof console !== 'undefined') {
127 + if (typeof localRequestAnimationFrame !== 'function') {
128 + console.error(
129 + "This browser doesn't support requestAnimationFrame. " +
130 + 'Make sure that you load a ' +
131 + 'polyfill in older browsers. https://fb.me/react-polyfills',
132 + );
133 + }
134 + if (typeof localCancelAnimationFrame !== 'function') {
135 + console.error(
136 + "This browser doesn't support cancelAnimationFrame. " +
137 + 'Make sure that you load a ' +
138 + 'polyfill in older browsers. https://fb.me/react-polyfills',
139 + );
140 + }
141 + }
142 }
143
144 let headOfPendingCallbacksLinkedList: CallbackConfigType | null = null;