Remove DevTools dependency on Scheduler runWithPriority (#20967)
This commit is contained in:
parent
e4d4b7074d
commit
ec372faefe
|
@ -34,12 +34,8 @@ import {
|
|||
useMemo,
|
||||
useReducer,
|
||||
useRef,
|
||||
unstable_startTransition as startTransition,
|
||||
} from 'react';
|
||||
import {
|
||||
unstable_next as next,
|
||||
unstable_runWithPriority as runWithPriority,
|
||||
unstable_UserBlockingPriority as UserBlockingPriority,
|
||||
} from 'scheduler';
|
||||
import {createRegExp} from '../utils';
|
||||
import {BridgeContext, StoreContext} from '../context';
|
||||
import Store from '../../store';
|
||||
|
@ -923,11 +919,10 @@ function TreeContextController({
|
|||
|
||||
const dispatchWrapper = useCallback(
|
||||
(action: Action) => {
|
||||
// Run the first update at "user-blocking" priority in case dispatch is called from a non-React event.
|
||||
// In this case, the current (and "next") priorities would both be "normal",
|
||||
// and suspense would potentially block both updates.
|
||||
runWithPriority(UserBlockingPriority, () => dispatch(action));
|
||||
next(() => dispatch({type: 'UPDATE_INSPECTED_ELEMENT_ID'}));
|
||||
dispatch(action);
|
||||
startTransition(() => {
|
||||
dispatch({type: 'UPDATE_INSPECTED_ELEMENT_ID'});
|
||||
});
|
||||
},
|
||||
[dispatch],
|
||||
);
|
||||
|
|
|
@ -1,54 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @flow
|
||||
*/
|
||||
|
||||
import * as React from 'react';
|
||||
import {Fragment, useCallback, useState} from 'react';
|
||||
import {
|
||||
unstable_IdlePriority as IdlePriority,
|
||||
unstable_LowPriority as LowPriority,
|
||||
unstable_runWithPriority as runWithPriority,
|
||||
} from 'scheduler';
|
||||
|
||||
export default function PriorityLevels() {
|
||||
const [defaultPriority, setDefaultPriority] = useState<boolean>(false);
|
||||
const [idlePriority, setIdlePriority] = useState<boolean>(false);
|
||||
const [normalPriority, setLowPriority] = useState<boolean>(false);
|
||||
|
||||
const resetSequence = useCallback(() => {
|
||||
setDefaultPriority(false);
|
||||
setLowPriority(false);
|
||||
setIdlePriority(false);
|
||||
}, []);
|
||||
|
||||
const startSequence = useCallback(() => {
|
||||
setDefaultPriority(true);
|
||||
runWithPriority(LowPriority, () => setLowPriority(true));
|
||||
runWithPriority(IdlePriority, () => setIdlePriority(true));
|
||||
}, []);
|
||||
|
||||
const labels = [];
|
||||
if (defaultPriority) {
|
||||
labels.push('(default priority)');
|
||||
}
|
||||
if (normalPriority) {
|
||||
labels.push('Low Priority');
|
||||
}
|
||||
if (idlePriority) {
|
||||
labels.push('Idle Priority');
|
||||
}
|
||||
|
||||
return (
|
||||
<Fragment>
|
||||
<h1>Priority Levels</h1>
|
||||
<button onClick={resetSequence}>Reset</button>
|
||||
<button onClick={startSequence}>Start sequence</button>
|
||||
<span>{labels.join(', ')}</span>
|
||||
</Fragment>
|
||||
);
|
||||
}
|
|
@ -15,7 +15,6 @@ import Hydration from './Hydration';
|
|||
import InlineWarnings from './InlineWarnings';
|
||||
import InspectableElements from './InspectableElements';
|
||||
import InteractionTracing from './InteractionTracing';
|
||||
import PriorityLevels from './PriorityLevels';
|
||||
import ReactNativeWeb from './ReactNativeWeb';
|
||||
import ToDoList from './ToDoList';
|
||||
import Toggle from './Toggle';
|
||||
|
@ -55,7 +54,6 @@ function mountTestApp() {
|
|||
mountHelper(ElementTypes);
|
||||
mountHelper(EditableProps);
|
||||
mountHelper(InlineWarnings);
|
||||
mountHelper(PriorityLevels);
|
||||
mountHelper(ReactNativeWeb);
|
||||
mountHelper(Toggle);
|
||||
mountHelper(SuspenseTree);
|
||||
|
|
Loading…
Reference in New Issue