mirror of
https://github.com/zebrajr/react.git
synced 2026-01-15 12:15:22 +00:00
chore[DevTools]: don't use batchedUpdate (#32074)
It is no-op for concurrent mode now and React DevTools is using experimental version of React:886c5ad936/packages/react-dom/src/shared/ReactDOM.js (L51-L54)540efebcc3/packages/react-reconciler/src/ReactFiberWorkLoop.js (L1646-L1651)
This commit is contained in:
@@ -9,7 +9,6 @@
|
||||
|
||||
import * as React from 'react';
|
||||
import {useContext, useMemo, useRef, useState} from 'react';
|
||||
import {unstable_batchedUpdates as batchedUpdates} from 'react-dom';
|
||||
import {copy} from 'clipboard-js';
|
||||
import {
|
||||
BridgeContext,
|
||||
@@ -178,10 +177,8 @@ function Row({
|
||||
validAttributes === null ||
|
||||
validAttributes.indexOf(newAttribute) >= 0;
|
||||
|
||||
batchedUpdates(() => {
|
||||
setLocalAttribute(newAttribute);
|
||||
setIsAttributeValid(isValid);
|
||||
});
|
||||
setLocalAttribute(newAttribute);
|
||||
setIsAttributeValid(isValid);
|
||||
};
|
||||
|
||||
// $FlowFixMe[missing-local-annot]
|
||||
@@ -192,10 +189,8 @@ function Row({
|
||||
isValid = true;
|
||||
} catch (error) {}
|
||||
|
||||
batchedUpdates(() => {
|
||||
setLocalValue(newValue);
|
||||
setIsValueValid(isValid);
|
||||
});
|
||||
setLocalValue(newValue);
|
||||
setIsValueValid(isValid);
|
||||
};
|
||||
|
||||
const resetAttribute = () => {
|
||||
|
||||
@@ -18,7 +18,6 @@ import {
|
||||
useMemo,
|
||||
useState,
|
||||
} from 'react';
|
||||
import {unstable_batchedUpdates as batchedUpdates} from 'react-dom';
|
||||
import {createResource} from 'react-devtools-shared/src/devtools/cache';
|
||||
import {
|
||||
BridgeContext,
|
||||
@@ -120,10 +119,8 @@ function NativeStyleContextController({children}: Props): React.Node {
|
||||
const request = inProgressRequests.get(element);
|
||||
if (request != null) {
|
||||
inProgressRequests.delete(element);
|
||||
batchedUpdates(() => {
|
||||
request.resolveFn(styleAndLayout);
|
||||
setCurrentStyleAndLayout(styleAndLayout);
|
||||
});
|
||||
request.resolveFn(styleAndLayout);
|
||||
setCurrentStyleAndLayout(styleAndLayout);
|
||||
} else {
|
||||
resource.write(element, styleAndLayout);
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ import type {ReactContext} from 'shared/ReactTypes';
|
||||
|
||||
import * as React from 'react';
|
||||
import {createContext, useCallback, useContext, useMemo, useState} from 'react';
|
||||
import {unstable_batchedUpdates as batchedUpdates} from 'react-dom';
|
||||
import {useLocalStorage, useSubscription} from '../hooks';
|
||||
import {
|
||||
TreeDispatcherContext,
|
||||
@@ -166,31 +165,28 @@ function ProfilerContextController({children}: Props): React.Node {
|
||||
);
|
||||
|
||||
if (prevProfilingData !== profilingData) {
|
||||
batchedUpdates(() => {
|
||||
setPrevProfilingData(profilingData);
|
||||
setPrevProfilingData(profilingData);
|
||||
|
||||
const dataForRoots =
|
||||
profilingData !== null ? profilingData.dataForRoots : null;
|
||||
if (dataForRoots != null) {
|
||||
const firstRootID = dataForRoots.keys().next().value || null;
|
||||
const dataForRoots =
|
||||
profilingData !== null ? profilingData.dataForRoots : null;
|
||||
if (dataForRoots != null) {
|
||||
const firstRootID = dataForRoots.keys().next().value || null;
|
||||
|
||||
if (rootID === null || !dataForRoots.has(rootID)) {
|
||||
let selectedElementRootID = null;
|
||||
if (inspectedElementID !== null) {
|
||||
selectedElementRootID =
|
||||
store.getRootIDForElement(inspectedElementID);
|
||||
}
|
||||
if (
|
||||
selectedElementRootID !== null &&
|
||||
dataForRoots.has(selectedElementRootID)
|
||||
) {
|
||||
setRootIDAndClearFiber(selectedElementRootID);
|
||||
} else {
|
||||
setRootIDAndClearFiber(firstRootID);
|
||||
}
|
||||
if (rootID === null || !dataForRoots.has(rootID)) {
|
||||
let selectedElementRootID = null;
|
||||
if (inspectedElementID !== null) {
|
||||
selectedElementRootID = store.getRootIDForElement(inspectedElementID);
|
||||
}
|
||||
if (
|
||||
selectedElementRootID !== null &&
|
||||
dataForRoots.has(selectedElementRootID)
|
||||
) {
|
||||
setRootIDAndClearFiber(selectedElementRootID);
|
||||
} else {
|
||||
setRootIDAndClearFiber(firstRootID);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const [isCommitFilterEnabled, setIsCommitFilterEnabled] =
|
||||
@@ -229,15 +225,13 @@ function ProfilerContextController({children}: Props): React.Node {
|
||||
);
|
||||
|
||||
if (isProfiling) {
|
||||
batchedUpdates(() => {
|
||||
if (selectedCommitIndex !== null) {
|
||||
selectCommitIndex(null);
|
||||
}
|
||||
if (selectedFiberID !== null) {
|
||||
selectFiberID(null);
|
||||
selectFiberName(null);
|
||||
}
|
||||
});
|
||||
if (selectedCommitIndex !== null) {
|
||||
selectCommitIndex(null);
|
||||
}
|
||||
if (selectedFiberID !== null) {
|
||||
selectFiberID(null);
|
||||
selectFiberName(null);
|
||||
}
|
||||
}
|
||||
|
||||
const value = useMemo(
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
|
||||
import * as React from 'react';
|
||||
import {Fragment, useContext, useEffect, useState} from 'react';
|
||||
import {unstable_batchedUpdates as batchedUpdates} from 'react-dom';
|
||||
import {ModalDialogContext} from './ModalDialog';
|
||||
import {StoreContext} from './context';
|
||||
import {UNSUPPORTED_VERSION_URL} from '../constants';
|
||||
@@ -26,14 +25,12 @@ export default function UnsupportedVersionDialog(_: {}): null {
|
||||
useEffect(() => {
|
||||
if (state === 'dialog-not-shown') {
|
||||
const showDialog = () => {
|
||||
batchedUpdates(() => {
|
||||
setState('show-dialog');
|
||||
dispatch({
|
||||
canBeDismissed: true,
|
||||
id: 'UnsupportedVersionDialog',
|
||||
type: 'SHOW',
|
||||
content: <DialogContent />,
|
||||
});
|
||||
setState('show-dialog');
|
||||
dispatch({
|
||||
canBeDismissed: true,
|
||||
id: 'UnsupportedVersionDialog',
|
||||
type: 'SHOW',
|
||||
content: <DialogContent />,
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user