From d0be7e10a7b9d6aefd2da70974bd0d2b0c80a60a Mon Sep 17 00:00:00 2001 From: Aryan Deora Date: Fri, 9 Jun 2023 13:57:53 -0400 Subject: [PATCH] fix(query-devtools): Fix getSidedProp bug --- packages/query-devtools/src/Devtools.tsx | 7 +++---- packages/react-query-devtools/src/devtools.tsx | 13 ++++++++++++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/packages/query-devtools/src/Devtools.tsx b/packages/query-devtools/src/Devtools.tsx index d0ee3d7060..150e2f431f 100644 --- a/packages/query-devtools/src/Devtools.tsx +++ b/packages/query-devtools/src/Devtools.tsx @@ -321,10 +321,9 @@ export const DevtoolsPanel: Component = (props) => { createEffect(() => { const rootContainer = panelRef.parentElement?.parentElement?.parentElement if (!rootContainer) return - const styleProp = getSidedProp( - 'padding', - props.localStore.position as DevtoolsPosition, - ) + const currentPosition = (props.localStore.position || + POSITION) as DevtoolsPosition + const styleProp = getSidedProp('padding', currentPosition) const isVertical = props.localStore.position === 'left' || props.localStore.position === 'right' diff --git a/packages/react-query-devtools/src/devtools.tsx b/packages/react-query-devtools/src/devtools.tsx index 551635e620..6531da9ecb 100644 --- a/packages/react-query-devtools/src/devtools.tsx +++ b/packages/react-query-devtools/src/devtools.tsx @@ -37,7 +37,7 @@ export interface DevtoolsOptions { errorTypes?: DevToolsErrorType[] } -export function ReactQueryDevtools( +function ReactQueryDevtoolsDev( props: DevtoolsOptions, ): React.ReactElement | null { const queryClient = useQueryClient() @@ -93,3 +93,14 @@ export function ReactQueryDevtools( return
} + +function ReactQueryDevtoolsProd( + _props: DevtoolsOptions, +): React.ReactElement | null { + return null +} + +export const ReactQueryDevtools: typeof ReactQueryDevtoolsDev = + process.env.NODE_ENV !== 'development' + ? ReactQueryDevtoolsProd + : ReactQueryDevtoolsDev