@@ -95,13 +95,13 @@ export interface TanStackDevtoolsReactInit {
95
95
96
96
const convertRender = (
97
97
Component : PluginRender ,
98
- setComponent : React . Dispatch < React . SetStateAction < JSX . Element | null > > ,
98
+ setComponents : React . Dispatch < React . SetStateAction < Array < JSX . Element > > > ,
99
99
e : HTMLElement ,
100
100
theme : 'dark' | 'light' ,
101
101
) => {
102
- setComponent (
103
- typeof Component === 'function' ? Component ( e , theme ) : Component ,
104
- )
102
+ const element =
103
+ typeof Component === 'function' ? Component ( e , theme ) : Component
104
+ setComponents ( ( prev ) => [ ... prev , element ] )
105
105
}
106
106
107
107
export const TanStackDevtools = ( {
@@ -130,41 +130,29 @@ export const TanStackDevtools = ({
130
130
name :
131
131
typeof plugin . name === 'string'
132
132
? plugin . name
133
- : // The check above confirms that `plugin.name` is of Render type
134
- ( e , theme ) => {
133
+ : ( e , theme ) => {
135
134
const target = e . ownerDocument . getElementById (
136
- // @ts -ignore just testing
137
- `${ PLUGIN_TITLE_CONTAINER_ID } -${ generatePluginId ( plugin , index ) } ` ,
135
+ `${ PLUGIN_TITLE_CONTAINER_ID } -${ generatePluginId ( plugin as TanStackDevtoolsPlugin , index ) } ` ,
138
136
)
139
137
if ( target ) {
140
138
setTitleContainers ( ( prev ) => [ ...prev , target ] )
141
139
}
142
140
convertRender (
143
141
plugin . name as PluginRender ,
144
- ( newVal ) =>
145
- // @ts -ignore just testing
146
- setTitleComponents ( ( prev ) => [ ...prev , newVal ] ) ,
142
+ setTitleComponents ,
147
143
e ,
148
144
theme ,
149
145
)
150
146
} ,
151
147
render : ( e , theme ) => {
152
148
const target = e . ownerDocument . getElementById (
153
- // @ts -ignore just testing
154
- `${ PLUGIN_CONTAINER_ID } -${ generatePluginId ( plugin , index ) } ` ,
149
+ `${ PLUGIN_CONTAINER_ID } -${ generatePluginId ( plugin as TanStackDevtoolsPlugin , index ) } ` ,
155
150
)
156
151
if ( target ) {
157
152
setPluginContainers ( ( prev ) => [ ...prev , target ] )
158
153
}
159
154
160
- convertRender (
161
- plugin . render ,
162
- ( newVal ) =>
163
- // @ts -ignore just testing
164
- setPluginComponents ( ( prev ) => [ ...prev , newVal ] ) ,
165
- e ,
166
- theme ,
167
- )
155
+ convertRender ( plugin . render , setPluginComponents , e , theme )
168
156
} ,
169
157
}
170
158
} ) ,
0 commit comments