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 , noop , onlineManager } from '@tanstack/query-core'
11
13
import { isPlatformBrowser } from '@angular/common'
@@ -270,14 +272,19 @@ export function withDevtools(
270
272
// Do not use provideEnvironmentInitializer while Angular < v19 is supported
271
273
provide : ENVIRONMENT_INITIALIZER ,
272
274
multi : true ,
273
- useFactory : ( ) => {
275
+ deps : [ Injector ] ,
276
+ useFactory : ( injector : Injector ) => {
274
277
if ( ! isPlatformBrowser ( inject ( PLATFORM_ID ) ) ) return noop
275
278
const injectedClient = inject ( QueryClient , {
276
279
optional : true ,
277
280
} )
278
281
const destroyRef = inject ( DestroyRef )
279
282
280
- const options = computed ( ( ) => withDevtoolsFn ?.( ) ?? { } )
283
+ const options = computed ( ( ) => {
284
+ return runInInjectionContext ( injector , ( ) => {
285
+ return withDevtoolsFn ?.( ) ?? { }
286
+ } )
287
+ } )
281
288
282
289
let devtools : TanstackQueryDevtools | null = null
283
290
let el : HTMLElement | null = null
You can’t perform that action at this time.
0 commit comments