Change async fixtures to use schedule

This commit is contained in:
Dan Abramov 2018-09-04 15:19:29 +01:00
parent 955393cab9
commit 2d5c590cc2
5 changed files with 11 additions and 33 deletions

View File

@ -13,12 +13,13 @@
"react-draggable": "^3.0.5"
},
"scripts": {
"prestart": "cp -r ../../../build/node_modules/* ./node_modules/",
"prebuild": "cp -r ../../../build/node_modules/* ./node_modules/",
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject",
"deploy": "gh-pages -d build",
"prestart": "cp -r ../../../build/node_modules/* ./node_modules/"
"deploy": "gh-pages -d build"
},
"eslintConfig": {
"extends": "./node_modules/react-scripts/config/eslint.js"

View File

@ -1,4 +1,5 @@
import React, {Placeholder, PureComponent} from 'react';
import {unstable_scheduleWork} from 'schedule';
import {
unstable_track as track,
unstable_wrap as wrap,
@ -37,7 +38,7 @@ export default class App extends PureComponent {
currentId: id,
})
);
requestIdleCallback(
unstable_scheduleWork(
wrap(() =>
track(`View ${id} (low-pri)`, performance.now(), () =>
this.setState({

View File

@ -4,14 +4,13 @@
"private": true,
"dependencies": {
"glamor": "^2.20.40",
"react": "../../../build/node_modules/react",
"react-dom": "../../../build/node_modules/react-dom",
"react-markdown": "^3.2.0",
"react-scripts": "^1.1.4",
"simple-cache-provider": "../../../build/node_modules/simple-cache-provider",
"victory": "^0.25.6"
},
"scripts": {
"prestart": "cp -r ../../../build/node_modules/* ./node_modules/",
"prebuild": "cp -r ../../../build/node_modules/* ./node_modules/",
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",

View File

@ -1,5 +1,6 @@
import React, {PureComponent} from 'react';
import {flushSync, render} from 'react-dom';
import {unstable_scheduleWork} from 'schedule';
import _ from 'lodash';
import Charts from './Charts';
import Clock from './Clock';
@ -66,7 +67,7 @@ class App extends PureComponent {
}
this._ignoreClick = true;
requestIdleCallback(() => {
unstable_scheduleWork(() => {
this.setState({showDemo: true}, () => {
this._ignoreClick = false;
});
@ -106,7 +107,7 @@ class App extends PureComponent {
this.debouncedHandleChange(value);
break;
case 'async':
requestIdleCallback(() => {
unstable_scheduleWork(() => {
this.setState({value});
});
break;

View File

@ -4136,7 +4136,7 @@ longest@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/longest/-/longest-1.0.1.tgz#30a0b2da38f73770e8294a0d22e6625ed77d0097"
loose-envify@^1.0.0, loose-envify@^1.1.0, loose-envify@^1.3.1:
loose-envify@^1.0.0, loose-envify@^1.3.1:
version "1.3.1"
resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.3.1.tgz#d1a8ad33fa9ce0e713d65fdd0ac8b748d478c848"
dependencies:
@ -5239,13 +5239,6 @@ prop-types@^15.5.10, prop-types@^15.6.0:
loose-envify "^1.3.1"
object-assign "^4.1.1"
prop-types@^15.6.2:
version "15.6.2"
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.6.2.tgz#05d5ca77b4453e985d60fc7ff8c859094a497102"
dependencies:
loose-envify "^1.3.1"
object-assign "^4.1.1"
proxy-addr@~2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-2.0.2.tgz#6571504f47bb988ec8180253f85dd7e14952bdec"
@ -5394,13 +5387,6 @@ react-dev-utils@^5.0.1:
strip-ansi "3.0.1"
text-table "0.2.0"
react-dom@../../../build/node_modules/react-dom:
version "16.4.1"
dependencies:
loose-envify "^1.1.0"
object-assign "^4.1.1"
prop-types "^15.6.2"
react-error-overlay@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/react-error-overlay/-/react-error-overlay-4.0.0.tgz#d198408a85b4070937a98667f500c832f86bd5d4"
@ -5460,13 +5446,6 @@ react-scripts@^1.1.4:
optionalDependencies:
fsevents "^1.1.3"
react@../../../build/node_modules/react:
version "16.4.1"
dependencies:
loose-envify "^1.1.0"
object-assign "^4.1.1"
prop-types "^15.6.2"
read-all-stream@^3.0.0:
version "3.1.0"
resolved "http://registry.npmjs.org/read-all-stream/-/read-all-stream-3.1.0.tgz#35c3e177f2078ef789ee4bfafa4373074eaef4fa"
@ -5985,9 +5964,6 @@ signal-exit@^3.0.0, signal-exit@^3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d"
simple-cache-provider@../../../build/node_modules/simple-cache-provider:
version "0.7.0"
slash@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/slash/-/slash-1.0.0.tgz#c41f2f6c39fc16d1cd17ad4b5d896114ae470d55"