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

plugin.tsx

29 lines699 Bytes

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