Skip to content

Commit ffc067d

Browse files
committed
fix: pass props to plugin component
1 parent 9688a40 commit ffc067d

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

examples/vue/basic/src/App.vue

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
<script lang="ts">
22
import { defineComponent, ref } from 'vue'
3-
import { TanStackDevtools } from '@tanstack/vue-devtools'
3+
import {
4+
TanStackDevtools,
5+
TanStackDevtoolsVuePlugin,
6+
} from '@tanstack/vue-devtools'
47
import { VueQueryDevtoolsPanel } from '@tanstack/vue-query-devtools'
58
69
import Posts from './Posts.vue'
@@ -19,7 +22,12 @@ export default defineComponent({
1922
postId.value = id
2023
}
2124
22-
const plugins = [{ name: 'Vue Query', component: VueQueryDevtoolsPanel }]
25+
const plugins: TanStackDevtoolsVuePlugin[] = [
26+
{
27+
name: 'Vue Query',
28+
component: VueQueryDevtoolsPanel,
29+
},
30+
]
2331
2432
return {
2533
isVisited,

packages/vue-devtools/src/types.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,10 @@ import type { Component } from 'vue'
22
import type {
33
ClientEventBusConfig,
44
TanStackDevtoolsConfig,
5-
TanStackDevtoolsPlugin,
65
} from '@tanstack/devtools'
76

8-
export type TanStackDevtoolsVuePlugin = Omit<
9-
TanStackDevtoolsPlugin,
10-
'render' | 'name'
11-
> & {
7+
export type TanStackDevtoolsVuePlugin = {
8+
id?: string
129
component: Component
1310
name: string | Component
1411
props?: Record<string, any>

packages/vue-devtools/src/vue-devtools.vue

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ import type {
1010
const props = defineProps<TanStackDevtoolsVueInit>()
1111
1212
const titlesToRender = shallowRef<Array<{ id: string; component: any }>>([])
13-
const pluginsToRender = shallowRef<Array<{ id: string; component: any }>>([])
13+
const pluginsToRender = shallowRef<
14+
Array<{ id: string; component: any; props: any }>
15+
>([])
1416
const div = ref<HTMLElement>()
1517
1618
function getPlugin(plugin: TanStackDevtoolsVuePlugin): TanStackDevtoolsPlugin {
@@ -33,7 +35,7 @@ function getPlugin(plugin: TanStackDevtoolsVuePlugin): TanStackDevtoolsPlugin {
3335
const id = e.getAttribute('id')!
3436
pluginsToRender.value = [
3537
...pluginsToRender.value,
36-
{ id, component: plugin.component },
38+
{ id, component: plugin.component, props: plugin.props },
3739
]
3840
},
3941
destroy: (pluginId) => {
@@ -83,6 +85,6 @@ onScopeDispose(() => {
8385
:key="plugin.id"
8486
:to="'#' + plugin.id"
8587
>
86-
<component :is="plugin.component" />
88+
<component :is="plugin.component" v-bind="plugin.props" />
8789
</Teleport>
8890
</template>

0 commit comments

Comments
 (0)