Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dedup conditional in ReactScheduler #12680

Merged
merged 1 commit into from
Apr 24, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 7 additions & 21 deletions packages/react-scheduler/src/ReactScheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,27 +100,13 @@ if (!ExecutionEnvironment.canUseDOM) {
let previousFrameTime = 33;
let activeFrameTime = 33;

let frameDeadlineObject;
if (hasNativePerformanceNow) {
frameDeadlineObject = {
didTimeout: false,
timeRemaining() {
// We assume that if we have a performance timer that the rAF callback
// gets a performance timer value. Not sure if this is always true.
const remaining = frameDeadline - performance.now();
return remaining > 0 ? remaining : 0;
},
};
} else {
frameDeadlineObject = {
didTimeout: false,
timeRemaining() {
// Fallback to Date.now()
const remaining = frameDeadline - Date.now();
return remaining > 0 ? remaining : 0;
},
};
}
const frameDeadlineObject = {
didTimeout: false,
timeRemaining() {
const remaining = frameDeadline - now();
return remaining > 0 ? remaining : 0;
},
};

// We use the postMessage trick to defer idle work until after the repaint.
const messageKey =
Expand Down