File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
packages/angular-query-experimental/src Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -2,10 +2,12 @@ import {
2
2
DestroyRef ,
3
3
ENVIRONMENT_INITIALIZER ,
4
4
InjectionToken ,
5
+ Injector ,
5
6
PLATFORM_ID ,
6
7
computed ,
7
8
effect ,
8
9
inject ,
10
+ runInInjectionContext ,
9
11
} from '@angular/core'
10
12
import { QueryClient , onlineManager } from '@tanstack/query-core'
11
13
import { isPlatformBrowser } from '@angular/common'
@@ -271,14 +273,19 @@ export function withDevtools(
271
273
// Do not use provideEnvironmentInitializer while Angular < v19 is supported
272
274
provide : ENVIRONMENT_INITIALIZER ,
273
275
multi : true ,
274
- useFactory : ( ) => {
276
+ deps : [ Injector ] ,
277
+ useFactory : ( injector : Injector ) => {
275
278
if ( ! isPlatformBrowser ( inject ( PLATFORM_ID ) ) ) return noop
276
279
const injectedClient = inject ( QueryClient , {
277
280
optional : true ,
278
281
} )
279
282
const destroyRef = inject ( DestroyRef )
280
283
281
- const options = computed ( ( ) => withDevtoolsFn ?.( ) ?? { } )
284
+ const options = computed ( ( ) => {
285
+ return runInInjectionContext ( injector , ( ) => {
286
+ return withDevtoolsFn ?.( ) ?? { }
287
+ } )
288
+ } )
282
289
283
290
let devtools : TanstackQueryDevtools | null = null
284
291
let el : HTMLElement | null = null
You can’t perform that action at this time.
0 commit comments