From 372445735eda4d7960419947c49499019adb79db Mon Sep 17 00:00:00 2001 From: Andrew Clark Date: Wed, 2 Aug 2017 19:56:37 +0530 Subject: [PATCH] Remove rAF export from ReactDOMFrameScheduling (#10337) Fiber doesn't schedule animation callbacks anymore (though it does use the browser's requestAnimationFrame to polyfill requestIdleCallback). This removes the rAF export from ReactDOMFrameScheduling, since it's not being used. --- .../shared/ReactDOMFrameScheduling.js | 28 +++---------------- 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/src/renderers/shared/ReactDOMFrameScheduling.js b/src/renderers/shared/ReactDOMFrameScheduling.js index 23c51724e2fb7..f519b099f1c1c 100644 --- a/src/renderers/shared/ReactDOMFrameScheduling.js +++ b/src/renderers/shared/ReactDOMFrameScheduling.js @@ -25,16 +25,10 @@ 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; +// TODO: There's no way to cancel, because Fiber doesn't atm. let rIC: (callback: (deadline: Deadline) => void) => number; if (!ExecutionEnvironment.canUseDOM) { - rAF = function(frameCallback: (time: number) => void): number { - setTimeout(frameCallback, 16); - return 0; - }; - rIC = function(frameCallback: (deadline: Deadline) => void): number { setTimeout(() => { frameCallback({ @@ -52,7 +46,7 @@ if (!ExecutionEnvironment.canUseDOM) { 'polyfill in older browsers.', ); } else if (typeof requestIdleCallback !== 'function') { - // Wrap requestAnimationFrame and polyfill requestIdleCallback. + // Polyfill requestIdleCallback. var scheduledRAFCallback = null; var scheduledRICCallback = null; @@ -90,7 +84,7 @@ if (!ExecutionEnvironment.canUseDOM) { isIdleScheduled = false; var callback = scheduledRICCallback; scheduledRICCallback = null; - if (callback) { + if (callback !== null) { callback(frameDeadlineObject); } }; @@ -130,23 +124,11 @@ if (!ExecutionEnvironment.canUseDOM) { } var callback = scheduledRAFCallback; scheduledRAFCallback = null; - if (callback) { + if (callback !== null) { callback(rafTime); } }; - rAF = function(callback: (time: number) => void): number { - // This assumes that we only schedule one callback at a time because that's - // how Fiber uses it. - scheduledRAFCallback = callback; - if (!isAnimationFrameScheduled) { - // If rIC didn't already schedule one, we need to schedule a frame. - isAnimationFrameScheduled = true; - requestAnimationFrame(animationTick); - } - return 0; - }; - rIC = function(callback: (deadline: Deadline) => void): number { // This assumes that we only schedule one callback at a time because that's // how Fiber uses it. @@ -162,9 +144,7 @@ if (!ExecutionEnvironment.canUseDOM) { return 0; }; } else { - rAF = requestAnimationFrame; rIC = requestIdleCallback; } -exports.rAF = rAF; exports.rIC = rIC;