(CoreClass: new () => TCoreDevtoolsClass)
| 23 | * ``` |
| 24 | */ |
| 25 | export function createPreactPanel< |
| 26 | TComponentProps extends DevtoolsPanelProps, |
| 27 | TCoreDevtoolsClass extends { |
| 28 | mount: (el: HTMLElement, props: TanStackDevtoolsPluginProps) => void |
| 29 | unmount: () => void |
| 30 | }, |
| 31 | >(CoreClass: new () => TCoreDevtoolsClass) { |
| 32 | function Panel(props: TComponentProps) { |
| 33 | const devToolRef = useRef<HTMLDivElement>(null) |
| 34 | const devtools = useRef<TCoreDevtoolsClass | null>(null) |
| 35 | useEffect(() => { |
| 36 | if (devtools.current) return |
| 37 | devtools.current = new CoreClass() |
| 38 | |
| 39 | if (devToolRef.current) { |
| 40 | devtools.current.mount(devToolRef.current, props) |
| 41 | } |
| 42 | |
| 43 | return () => { |
| 44 | if (devToolRef.current) { |
| 45 | devtools.current?.unmount() |
| 46 | devtools.current = null |
| 47 | } |
| 48 | } |
| 49 | }, [props]) |
| 50 | |
| 51 | return <div style={{ height: '100%' }} ref={devToolRef} /> |
| 52 | } |
| 53 | |
| 54 | function NoOpPanel(_props: TComponentProps) { |
| 55 | return <></> |
| 56 | } |
| 57 | return [Panel, NoOpPanel] as const |
| 58 | } |
nothing calls this directly
no outgoing calls
no test coverage detected