Skip to content

Commit 27c16fd

Browse files
committed
feat: update id getter
1 parent d45e600 commit 27c16fd

3 files changed

Lines changed: 8 additions & 14 deletions

File tree

‎packages/devtools/src/context/devtools-context.tsx‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,7 @@ const getSettings = () => {
8686
}
8787
}
8888

89-
export const generatePluginId = (
90-
plugin: TanStackDevtoolsPlugin,
91-
index: number,
92-
) => {
89+
const generatePluginId = (plugin: TanStackDevtoolsPlugin, index: number) => {
9390
// if set by user, return the plugin id
9491
if (plugin.id) {
9592
return plugin.id

‎packages/devtools/src/index.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,3 @@ export type {
55
TanStackDevtoolsPlugin,
66
TanStackDevtoolsConfig,
77
} from './context/devtools-context'
8-
export { generatePluginId } from './context/devtools-context'

‎packages/react-devtools/src/devtools.tsx‎

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
import React, { useEffect, useRef, useState } from 'react'
2-
import {
3-
PLUGIN_CONTAINER_ID,
4-
PLUGIN_TITLE_CONTAINER_ID,
5-
TanStackDevtoolsCore,
6-
generatePluginId,
7-
} from '@tanstack/devtools'
2+
import { TanStackDevtoolsCore } from '@tanstack/devtools'
83
import { createPortal } from 'react-dom'
94
import type { JSX, ReactElement } from 'react'
105
import type {
@@ -124,19 +119,21 @@ export const TanStackDevtools = ({
124119
new TanStackDevtoolsCore({
125120
config,
126121
eventBusConfig,
127-
plugins: plugins?.map((plugin, index) => {
122+
plugins: plugins?.map((plugin) => {
128123
return {
129124
...plugin,
130125
name:
131126
typeof plugin.name === 'string'
132127
? plugin.name
133128
: (e, theme) => {
134129
const target = e.ownerDocument.getElementById(
135-
`${PLUGIN_TITLE_CONTAINER_ID}-${generatePluginId(plugin as TanStackDevtoolsPlugin, index)}`,
130+
e.getAttribute('id')!,
136131
)
132+
137133
if (target) {
138134
setTitleContainers((prev) => [...prev, target])
139135
}
136+
140137
convertRender(
141138
plugin.name as PluginRender,
142139
setTitleComponents,
@@ -146,8 +143,9 @@ export const TanStackDevtools = ({
146143
},
147144
render: (e, theme) => {
148145
const target = e.ownerDocument.getElementById(
149-
`${PLUGIN_CONTAINER_ID}-${generatePluginId(plugin as TanStackDevtoolsPlugin, index)}`,
146+
e.getAttribute('id')!,
150147
)
148+
151149
if (target) {
152150
setPluginContainers((prev) => [...prev, target])
153151
}

0 commit comments

Comments
 (0)