diff --git a/packages/solid-query-devtools/src/clientOnly.tsx b/packages/solid-query-devtools/src/clientOnly.tsx index 379bd78ad71..4ad47920575 100644 --- a/packages/solid-query-devtools/src/clientOnly.tsx +++ b/packages/solid-query-devtools/src/clientOnly.tsx @@ -1,5 +1,5 @@ import { - createMemo, + createComponent, createSignal, onMount, sharedConfig, @@ -9,35 +9,34 @@ import { import { isServer } from 'solid-js/web' import type { Component, ComponentProps, JSX } from 'solid-js' -/* - This function has been taken from solid-start's codebase - This allows the devtools to be loaded only on the client and bypasses any server side rendering - https://github.com/solidjs/solid-start/blob/2967fc2db3f0df826f061020231dbdafdfa0746b/packages/start/islands/clientOnly.tsx -*/ export default function clientOnly>( fn: () => Promise<{ default: T }>, ) { - if (isServer) + if (isServer) { return (props: ComponentProps & { fallback?: JSX.Element }) => props.fallback + } const [comp, setComp] = createSignal() fn().then((m) => setComp(() => m.default)) - return (props: ComponentProps) => { + + return (props: ComponentProps & { fallback?: JSX.Element }) => { let Comp: T | undefined - let m: boolean const [, rest] = splitProps(props, ['fallback']) - if ((Comp = comp()) && !sharedConfig.context) return Comp(rest) + + if ((Comp = comp()) && !sharedConfig.context) { + return createComponent(Comp, rest) + } + const [mounted, setMounted] = createSignal(!sharedConfig.context) onMount(() => setMounted(true)) - return createMemo( - () => ( - (Comp = comp()), - (m = mounted()), - untrack(() => (Comp && m ? Comp(rest) : props.fallback)) - ), - ) + + return untrack(() => { + const C = comp() + const m = mounted() + return C && m ? createComponent(C, rest) : props.fallback + }) } -} +} \ No newline at end of file diff --git a/packages/solid-query-devtools/src/index.tsx b/packages/solid-query-devtools/src/index.tsx index e6fd3ba983e..7f9a1bb3409 100644 --- a/packages/solid-query-devtools/src/index.tsx +++ b/packages/solid-query-devtools/src/index.tsx @@ -15,4 +15,4 @@ export const SolidQueryDevtoolsPanel: typeof SolidQueryDevtoolsCompPanel = isDev return null } -export type { DevtoolsPanelOptions } from './devtoolsPanel' +export type { DevtoolsPanelOptions } from './devtoolsPanel' \ No newline at end of file diff --git a/packages/solid-query-devtools/vite.config.ts b/packages/solid-query-devtools/vite.config.ts index ced61035f13..cc2570bcb30 100644 --- a/packages/solid-query-devtools/vite.config.ts +++ b/packages/solid-query-devtools/vite.config.ts @@ -4,7 +4,7 @@ import solid from 'vite-plugin-solid' import packageJson from './package.json' export default defineConfig({ - plugins: [solid()], + plugins: [solid({ hot: false })], // fix from https://github.com/vitest-dev/vitest/issues/6992#issuecomment-2509408660 resolve: { conditions: ['@tanstack/custom-condition'], @@ -31,4 +31,4 @@ export default defineConfig({ typecheck: { enabled: true }, restoreMocks: true, }, -}) +}) \ No newline at end of file