|
1 |
| -import { |
2 |
| - createEffect, |
3 |
| - createMemo, |
4 |
| - createSignal, |
5 |
| - onCleanup, |
6 |
| - onMount, |
7 |
| - sharedConfig, |
8 |
| - splitProps, |
9 |
| - untrack, |
10 |
| -} from 'solid-js' |
| 1 | +import { createEffect, createMemo, onCleanup, onMount } from 'solid-js' |
11 | 2 | import { onlineManager, useQueryClient } from '@tanstack/solid-query'
|
12 |
| -import { isServer } from 'solid-js/web' |
13 | 3 | import { TanstackQueryDevtools } from '@tanstack/query-devtools'
|
14 | 4 | import type {
|
15 | 5 | DevtoolsButtonPosition,
|
16 | 6 | DevtoolsErrorType,
|
17 | 7 | DevtoolsPosition,
|
18 | 8 | } from '@tanstack/query-devtools'
|
19 | 9 | import type { QueryClient } from '@tanstack/solid-query'
|
20 |
| -import type { Component, ComponentProps, JSX } from 'solid-js' |
21 | 10 |
|
22 | 11 | interface DevtoolsOptions {
|
23 | 12 | /**
|
@@ -104,36 +93,3 @@ export default function SolidQueryDevtools(props: DevtoolsOptions) {
|
104 | 93 |
|
105 | 94 | return <div class="tsqd-parent-container" ref={ref}></div>
|
106 | 95 | }
|
107 |
| - |
108 |
| -/* |
109 |
| - This function has been taken from solid-start's codebase |
110 |
| - This allows the devtools to be loaded only on the client and bypasses any server side rendering |
111 |
| - https://github.com/solidjs/solid-start/blob/2967fc2db3f0df826f061020231dbdafdfa0746b/packages/start/islands/clientOnly.tsx |
112 |
| -*/ |
113 |
| -export function clientOnly<T extends Component<any>>( |
114 |
| - fn: () => Promise<{ |
115 |
| - default: T |
116 |
| - }>, |
117 |
| -) { |
118 |
| - if (isServer) |
119 |
| - return (props: ComponentProps<T> & { fallback?: JSX.Element }) => |
120 |
| - props.fallback |
121 |
| - |
122 |
| - const [comp, setComp] = createSignal<T>() |
123 |
| - fn().then((m) => setComp(() => m.default)) |
124 |
| - return (props: ComponentProps<T>) => { |
125 |
| - let Comp: T | undefined |
126 |
| - let m: boolean |
127 |
| - const [, rest] = splitProps(props, ['fallback']) |
128 |
| - if ((Comp = comp()) && !sharedConfig.context) return Comp(rest) |
129 |
| - const [mounted, setMounted] = createSignal(!sharedConfig.context) |
130 |
| - onMount(() => setMounted(true)) |
131 |
| - return createMemo( |
132 |
| - () => ( |
133 |
| - (Comp = comp()), |
134 |
| - (m = mounted()), |
135 |
| - untrack(() => (Comp && m ? Comp(rest) : props.fallback)) |
136 |
| - ), |
137 |
| - ) |
138 |
| - } |
139 |
| -} |
0 commit comments