Skip to content

Commit 79ded80

Browse files
chore: fix issue with core class (#171)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
1 parent e77127a commit 79ded80

File tree

4 files changed

+15
-12
lines changed

4 files changed

+15
-12
lines changed

.changeset/free-women-film.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 issues with mounting

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ export function createReactPanel<
4141
}
4242

4343
return () => {
44-
devtools.current?.unmount()
44+
if (devToolRef.current) {
45+
devtools.current?.unmount()
46+
}
4547
}
4648
}, [props?.theme])
4749

packages/devtools-utils/src/solid/class.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ export function constructCoreClass(Component: () => JSX.Element) {
2828
}
2929
const mountTo = el
3030
const dispose = render(() => {
31-
// eslint-disable-next-line @typescript-eslint/require-await
32-
this.#Component = lazy(async () => ({ default: Component }))
31+
this.#Component = Component
3332

3433
this.#ThemeProvider = lazy(() =>
3534
import('@tanstack/devtools-ui').then((mod) => ({

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

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** @jsxImportSource solid-js - we use Solid.js as JSX here */
22

3-
import { onCleanup, onMount } from 'solid-js'
3+
import { createSignal, onCleanup, onMount } from 'solid-js'
44
import type { ClassType } from './class'
55

66
export interface DevtoolsPanelProps {
@@ -12,17 +12,14 @@ export function createSolidPanel<
1212
>(CoreClass: ClassType) {
1313
function Panel(props: TComponentProps) {
1414
let devToolRef: HTMLDivElement | undefined
15-
15+
const [devtools] = createSignal(new CoreClass())
1616
onMount(() => {
17-
const devtools = new CoreClass()
18-
1917
if (devToolRef) {
20-
devtools.mount(devToolRef, props?.theme ?? 'dark')
21-
22-
onCleanup(() => {
23-
devtools.unmount()
24-
})
18+
devtools().mount(devToolRef, props?.theme ?? 'dark')
2519
}
20+
onCleanup(() => {
21+
devtools().unmount()
22+
})
2623
})
2724

2825
return <div style={{ height: '100%' }} ref={devToolRef} />

0 commit comments

Comments
 (0)