Open History to see the last commit
1/** @jsxImportSource solid-js - we use Solid.js as JSX here */
2β
3import { createSignal, onCleanup, onMount } from 'solid-js'
4import type { ClassType } from './class'
5import type { TanStackDevtoolsPluginProps } from '@tanstack/devtools'
6β
7export interface DevtoolsPanelProps extends TanStackDevtoolsPluginProps {}
8β
9export function createSolidPanel<TComponentProps extends DevtoolsPanelProps>(
10 CoreClass: ClassType,
11) {
12 function Panel(props: TComponentProps) {
13 let devToolRef: HTMLDivElement | undefined
14 const [devtools] = createSignal(new CoreClass())
15 onMount(() => {
16 if (devToolRef) {
17 devtools().mount(devToolRef, props)
18 }
19 onCleanup(() => {
20 devtools().unmount()
21 })
22 })
23β
24 return <div style={{ height: '100%' }} ref={devToolRef} />
25 }
26β
27 function NoOpPanel(_props: TComponentProps) {
28 return <></>
29 }
30β
31 return [Panel, NoOpPanel] as const
32}