mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
79a740c6e3
**what is the change?:** In a recent PR we were referencing some global variables and storing local references to them. To make things more natural, we co-opted the original name of the global for our local reference. To make this work with Flow, we get the original reference from 'window.requestAnimationFrame' and assign it to 'const requestAnimationFrame'. Sometimes React is used in an environment where 'window' is not defined - in that case we need to use something else, or hide the 'window' reference somewhere. We opted to use 'global' thinking that Babel transforms would fill that in with the proper thing. But for some of our fixtures we are not doing that transform on the bundle. **why make this change?:** I want to unbreak this on master and then investigate more about what we should do to fix this. **test plan:** run `yarn build` and open the fixtures. **issue:** https://github.com/facebook/react/issues/12930
34 lines
896 B
JavaScript
34 lines
896 B
JavaScript
/**
|
|
* Copyright (c) 2013-present, Facebook, Inc.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @flow
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
import ExecutionEnvironment from 'fbjs/lib/ExecutionEnvironment';
|
|
import warning from 'fbjs/lib/warning';
|
|
|
|
// We capture a local reference to any global, in case it gets polyfilled after
|
|
// this module is initially evaluated.
|
|
// We want to be using a consistent implementation.
|
|
const localRequestAnimationFrame = requestAnimationFrame;
|
|
|
|
if (__DEV__) {
|
|
if (
|
|
ExecutionEnvironment.canUseDOM &&
|
|
typeof localRequestAnimationFrame !== 'function'
|
|
) {
|
|
warning(
|
|
false,
|
|
'React depends on requestAnimationFrame. Make sure that you load a ' +
|
|
'polyfill in older browsers. https://fb.me/react-polyfills',
|
|
);
|
|
}
|
|
}
|
|
|
|
export default localRequestAnimationFrame;
|