mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
9b36df86c6
* Don't call idle callback unless there's time remaining * Expiration fixture Fixture that demonstrates how async work expires after a certain interval. The fixture clogs the main thread with animation work, so it only works if the `timeout` option is provided to `requestIdleCallback`. * Pass timeout option to requestIdleCallback Forces `requestIdleCallback` to fire if too much time has elapsed, even if the main thread is busy. Required to make expiration times work properly. Otherwise, async work can expire, but React never has a chance to flush it because the browser never calls into React.
22 lines
402 B
JavaScript
22 lines
402 B
JavaScript
/* eslint-disable */
|
|
global.__DEV__ = true;
|
|
|
|
// For testing DOM Fiber.
|
|
global.requestAnimationFrame = function(callback) {
|
|
setTimeout(callback);
|
|
};
|
|
|
|
global.requestIdleCallback = function(callback) {
|
|
return setTimeout(() => {
|
|
callback({
|
|
timeRemaining() {
|
|
return Infinity;
|
|
},
|
|
});
|
|
});
|
|
};
|
|
|
|
global.cancelIdleCallback = function(callbackID) {
|
|
clearTimeout(callbackID);
|
|
};
|