Skip to content

Commit 650b8f5

Browse files
committed
fix: unmounting of devtools
1 parent 21ecc4a commit 650b8f5

2 files changed

Lines changed: 10 additions & 7 deletions

File tree

.changeset/fine-pugs-press.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@tanstack/devtools-utils': patch
3+
---
4+
5+
fix issue with unmounting of devtools

packages/devtools-utils/src/react/panel.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,16 @@ export function createReactPanel<
3232
const devToolRef = useRef<HTMLDivElement>(null)
3333
const devtools = useRef<TCoreDevtoolsClass | null>(null)
3434
useEffect(() => {
35-
if (devtools.current) return
36-
37-
devtools.current = new CoreClass()
35+
const instance = new CoreClass()
36+
devtools.current = instance
3837

3938
if (devToolRef.current) {
40-
devtools.current.mount(devToolRef.current, props?.theme ?? 'dark')
39+
instance.mount(devToolRef.current, props?.theme ?? 'dark')
4140
}
4241

4342
return () => {
44-
if (devToolRef.current) {
45-
devtools.current?.unmount()
46-
}
43+
instance.unmount()
44+
devtools.current = null
4745
}
4846
}, [props?.theme])
4947

0 commit comments

Comments
 (0)