Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(api): introduce inspectSetupState #450

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

alexzhang1030
Copy link
Member

@alexzhang1030 alexzhang1030 commented Jun 16, 2024

closes #376

This is very useful when using defineComponent with setup returning the render function.

const Component = defineComponent({
  setup() {
    const name = ref('foo')
    inspectSetupState({
      name,
    })
    return h('div', name.value)
  },
})

Copy link

netlify bot commented Jun 16, 2024

Deploy Preview for vue-devtools-docs canceled.

Name Link
🔨 Latest commit 0b6464b
🔍 Latest deploy log https://app.netlify.com/sites/vue-devtools-docs/deploys/66d7bd95a1973000086a777b

@webfansplz
Copy link
Member

webfansplz commented Jun 16, 2024

I’m not sure about it. I don't think most users will use it manually to inspect it. If we can't handle it automatically in devtools at the moment, I think the better solution is to expose some possibilities in vue core.
But it might work as a helper to help some developers who want this feature, I'll check it out later!

@alexzhang1030
Copy link
Member Author

I’m sure about it. I don't think most users will use it manually to inspect it. If we can't handle it automatically in devtools at the moment, I think the better solution is to expose some possibilities in vue core. But it might work as a helper to help some developers who want this feature, I'll check it out later!

If the setup returns a render function, which will be a closure, it becomes challenging for vue/core to register the setup state without static analysis. An existing PR, #5383, aims to add a debug API. However, I believe it would be more appropriate to integrate this function into vue-devtools.

Copy link

pkg-pr-new bot commented Sep 4, 2024

Open in Stackblitz

@vue/devtools-core

pnpm add https://pkg.pr.new/@vue/devtools-core@450

@vue/devtools

pnpm add https://pkg.pr.new/@vue/devtools@450

@vue/devtools-api

pnpm add https://pkg.pr.new/@vue/devtools-api@450

@vue/devtools-kit

pnpm add https://pkg.pr.new/@vue/devtools-kit@450

vite-plugin-vue-devtools

pnpm add https://pkg.pr.new/vite-plugin-vue-devtools@450

commit: 0b6464b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

When setup returns a render function, is it possible to obtain the state of refs?
2 participants