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

Support automatic ref unwrapping in plugin-vue-jsx #4103

Closed
4 tasks done
bbugh opened this issue Jul 3, 2021 · 2 comments
Closed
4 tasks done

Support automatic ref unwrapping in plugin-vue-jsx #4103

bbugh opened this issue Jul 3, 2021 · 2 comments

Comments

@bbugh
Copy link

bbugh commented Jul 3, 2021

Clear and concise description of the problem

I searched around and was surprised not to see any issues about this topic; I apologize if it's a duplicate.

JSX with Vue works great in vite, but it's very easy to forget which items are computed/refs and require .value

const App = defineComponent({
  setup() {
    const quantity = 100;
    const uom = "kg";
    const amount = computed(() => `${quantity} ${uom}`);

    return () => (
      <div class="bg-red-300">
        quantity: {quantity}, uom: {uom};{" "}
        {/* ☹️ Invalid VNode type: undefined (undefined) at <App> */}
        You have {amount} of potatoes.
      </div>
    );
  },
});

Suggested solution

It would be really nice if the compiler was able to automatically unwrap ComputedRef and Ref without having to explicitly state .value, like SFCs do.

Alternative

Using .value everywhere in templates

Additional context

No response

Validations

@patak-dev
Copy link
Member

Hey @bbugh, this is not something in the scope of Vite Core. Check out vuejs/rfcs#228 if you would like to see some ideas that the Vue community is thinking on to tackle this issue, but for reference Vite Core is framework agnostic so this kind of features should be implemented by each framework community through plugins.

@bbugh
Copy link
Author

bbugh commented Jul 3, 2021

Oh dang, sorry. That explains why I couldn't find anything. Thank you!

@github-actions github-actions bot locked and limited conversation to collaborators Jul 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants