Skip to content
Source
Sign inSign up
TanStack/devtools
Open History to see the last commit

plugin.tsx

31 lines773 Bytes

1/** @jsxImportSource solid-js - we use Solid.js as JSX here */
2​
3import type { JSX } from 'solid-js'
4import type { DevtoolsPanelProps } from './panel'
5import type { TanStackDevtoolsPluginProps } from '@tanstack/devtools'
6​
7export function createSolidPlugin({
8 Component,
9 ...config
10}: {
11 name: string
12 id?: string
13 defaultOpen?: boolean
14 Component: (props: DevtoolsPanelProps) => JSX.Element
15}) {
16 function Plugin() {
17 return {
18 ...config,
19 render: (_el: HTMLElement, props: TanStackDevtoolsPluginProps) => {
20 return <Component {...props} />
21 },
22 }
23 }
24 function NoOpPlugin() {
25 return {
26 ...config,
27 render: (_el: HTMLElement, _props: TanStackDevtoolsPluginProps) => <></>,
28 }
29 }
30 return [Plugin, NoOpPlugin] as const