Skip to content

Commit 3e3a04e

Browse files
committed
fix(react-query-devtools): always useEffect for the mounted check
no effect runs on the server, and there is no real advantage to useLayoutEffect on the client; somehow, this dynamic check creates problems with the production build of the devtools
1 parent aab8e1e commit 3e3a04e

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

packages/react-query-devtools/src/devtools.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,6 @@ interface DevtoolsPanelOptions extends ContextOptions {
9999
handleDragStart: (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => void
100100
}
101101

102-
const isServer = typeof window === 'undefined'
103-
104102
export function ReactQueryDevtools({
105103
initialIsOpen,
106104
panelProps = {},
@@ -192,7 +190,7 @@ export function ReactQueryDevtools({
192190
}
193191
}, [isResolvedOpen])
194192

195-
React[isServer ? 'useEffect' : 'useLayoutEffect'](() => {
193+
React.useEffect(() => {
196194
if (isResolvedOpen) {
197195
const previousValue = rootRef.current?.parentElement?.style.paddingBottom
198196

packages/react-query-devtools/src/utils.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import type { Query } from '@tanstack/react-query'
44
import { Theme, useTheme } from './theme'
55
import useMediaQuery from './useMediaQuery'
66

7-
export const isServer = typeof window === 'undefined'
8-
97
type StyledComponent<T> = T extends 'button'
108
? React.DetailedHTMLProps<
119
React.ButtonHTMLAttributes<HTMLButtonElement>,
@@ -104,7 +102,7 @@ export function useIsMounted() {
104102
const mountedRef = React.useRef(false)
105103
const isMounted = React.useCallback(() => mountedRef.current, [])
106104

107-
React[isServer ? 'useEffect' : 'useLayoutEffect'](() => {
105+
React.useEffect(() => {
108106
mountedRef.current = true
109107
return () => {
110108
mountedRef.current = false

0 commit comments

Comments
 (0)