Skip to content

Commit b98796b

Browse files
authored
[devtools] Remove unnecessary cascading update (vercel#82295)
1 parent 75f33f0 commit b98796b

File tree

1 file changed

+7
-6
lines changed
  • packages/next/src/next-devtools/dev-overlay/components/devtools-indicator

1 file changed

+7
-6
lines changed

packages/next/src/next-devtools/dev-overlay/components/devtools-indicator/next-logo.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useEffect, useRef, useState } from 'react'
1+
import { useRef, useState } from 'react'
22
import { useUpdateAnimation } from './hooks/use-update-animation'
33
import { useMeasureWidth } from './hooks/use-measure-width'
44
import { useMinimumLoadingTimeMultiple } from './hooks/use-minimum-loading-time-multiple'
@@ -28,6 +28,12 @@ export function NextLogo({
2828

2929
const hasError = totalErrorCount > 0
3030
const [isErrorExpanded, setIsErrorExpanded] = useState(hasError)
31+
const [previousHasError, setPreviousHasError] = useState(hasError)
32+
if (previousHasError !== hasError) {
33+
setPreviousHasError(hasError)
34+
// Reset the expanded state when the error state changes
35+
setIsErrorExpanded(hasError)
36+
}
3137
const [dismissed, setDismissed] = useState(false)
3238
const newErrorDetected = useUpdateAnimation(
3339
totalErrorCount,
@@ -43,11 +49,6 @@ export function NextLogo({
4349
const isExpanded = isErrorExpanded || state.disableDevIndicator
4450
const width = measuredWidth === 0 ? 'auto' : measuredWidth
4551

46-
useEffect(() => {
47-
// eslint-disable-next-line react-hooks/react-compiler -- TODO
48-
setIsErrorExpanded(hasError)
49-
}, [hasError])
50-
5152
return (
5253
<div
5354
data-next-badge-root

0 commit comments

Comments
 (0)