MCPcopy Create free account
hub / github.com/TanStack/devtools / TanStackDevtools

Function TanStackDevtools

packages/preact-devtools/src/devtools.tsx:167–307  ·  view source on GitHub ↗
({
  plugins,
  config,
  eventBusConfig,
}: TanStackDevtoolsPreactInit)

Source from the content-addressed store, hash-verified

165}
166
167export const TanStackDevtools = ({
168 plugins,
169 config,
170 eventBusConfig,
171}: TanStackDevtoolsPreactInit): JSX.Element | null => {
172 const devToolRef = useRef<HTMLDivElement>(null)
173
174 const [pluginContainers, setPluginContainers] = useState<
175 Record<string, HTMLElement>
176 >({})
177 const [titleContainers, setTitleContainers] = useState<
178 Record<string, HTMLElement>
179 >({})
180 const [triggerContainer, setTriggerContainer] = useState<HTMLElement | null>(
181 null,
182 )
183
184 const [PluginComponents, setPluginComponents] = useState<
185 Record<string, JSX.Element>
186 >({})
187 const [TitleComponents, setTitleComponents] = useState<
188 Record<string, JSX.Element>
189 >({})
190 const [TriggerComponent, setTriggerComponent] = useState<JSX.Element | null>(
191 null,
192 )
193
194 const pluginsMap: Array<TanStackDevtoolsPlugin> = useMemo(
195 () =>
196 plugins?.map((plugin) => {
197 return {
198 ...plugin,
199 name:
200 typeof plugin.name === 'string'
201 ? plugin.name
202 : (e, theme) => {
203 const id = e.getAttribute('id')!
204 const target = e.ownerDocument.getElementById(id)
205
206 if (target) {
207 setTitleContainers((prev) => ({
208 ...prev,
209 [id]: e,
210 }))
211 }
212
213 convertRender(
214 plugin.name as PluginRender,
215 setTitleComponents,
216 e,
217 theme,
218 )
219 },
220 render: (e, theme) => {
221 const id = e.getAttribute('id')!
222 const target = e.ownerDocument.getElementById(id)
223
224 if (target) {

Callers

nothing calls this directly

Calls 5

setConfigMethod · 0.80
convertRenderFunction · 0.70
convertTriggerFunction · 0.70
mountMethod · 0.45
unmountMethod · 0.45

Tested by

no test coverage detected