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