Composition-api: [feature request] Support `setup()` returning `render` function with JSX

Created on 3 Jul 2019  路  7Comments  路  Source: vuejs/composition-api

@liximomo (related to #13) It would be great if we could do like this:

# compoennt.js
export default createComponent({
  setup() {
    const a = value(1)
    return () => <div> { a } </div>
})

This would make all type inference and refactoring super easy within VSCode.

enhancement

Most helpful comment

Supported in v2.2.0

All 7 comments

I don't think that's what setup() is meant to be, for components, since template is a separate option.
Also value unwrapping isn't clear here.

@phiter it's part of the RFC

https://github.com/vuejs/rfcs/blob/function-apis/active-rfcs/0000-function-api.md#usage-with-manual-render-functions

Oh I see. You gotta access values with .value inside the jsx then.

You don't necessarily have too use .value it's only when you use the value() wrapper. If you use state or anything that doesn't use .value then you don't need too. It's just that the example used a value() and this requires a .value

@IceSentry I am afraid that computed needs .value just like value.

Yes, you are right, I didn't check the RFC before posting, my point still stands that .value is not related to render functions. It's just that the example used that particular value() wrapper.

Supported in v2.2.0

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lixpng picture lixpng  路  6Comments

zzachattack2 picture zzachattack2  路  3Comments

SeregPie picture SeregPie  路  6Comments

kwanjas3 picture kwanjas3  路  4Comments

TooBug picture TooBug  路  6Comments