Skip to content

Commit

Permalink
Attempt fixing facebook#9102. Fake polyfill rAF (and rIC)
Browse files Browse the repository at this point in the history
  • Loading branch information
ManasJayanth committed Apr 25, 2017
1 parent d12c41c commit 12fcce7
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/renderers/shared/ReactDOMFrameScheduling.js
Expand Up @@ -23,11 +23,29 @@
import type {Deadline} from 'ReactFiberReconciler';

var invariant = require('fbjs/lib/invariant');
var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');

// TODO: There's no way to cancel these, because Fiber doesn't atm.
let rAF: (callback: (time: number) => void) => number;
let rIC: (callback: (deadline: Deadline) => void) => number;
if (typeof requestAnimationFrame !== 'function') {

if (!ExecutionEnvironment.canUseDOM) {
rAF = function(frameCallback: (time: number) => void): number {
setTimeout(frameCallback, 16);
return 0;
};

rIC = function(frameCallback: (deadline: Deadline) => void): number {
setTimeout(() => {
frameCallback({
timeRemaining() {
return Infinity;
},
});
});
return 0;
};
} else if (typeof requestAnimationFrame !== 'function') {
invariant(
false,
'React depends on requestAnimationFrame. Make sure that you load a ' +
Expand Down

0 comments on commit 12fcce7

Please sign in to comment.