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'
10
+ import type { JSX } from 'solid-js'
21
11
22
12
interface DevtoolsOptions {
23
13
/**
@@ -40,6 +30,10 @@ interface DevtoolsOptions {
40
30
* Custom instance of QueryClient
41
31
*/
42
32
client ?: QueryClient
33
+ /**
34
+ * Fallback component to show while the devtools are loading.
35
+ */
36
+ fallback ?: JSX . Element
43
37
/**
44
38
* Use this so you can define custom errors that can be shown in the devtools.
45
39
*/
@@ -104,36 +98,3 @@ export default function SolidQueryDevtools(props: DevtoolsOptions) {
104
98
105
99
return < div class = "tsqd-parent-container" ref = { ref } > </ div >
106
100
}
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