Closed
Description
I'm not sure if this is an issue or I'm doing something wrong, but currently I got "context.slots" an empty object in setup(), although it's available in lifecycle hook functions
import { onMounted, createElement as h } from '@vue/composition-api'
export default {
name: 'HelloWorld',
props: {
msg: String
},
setup(props, context) {
console.log(context.slots) // EMPTY OBJECT HERE
onMounted(() => {
console.log(context.slots) // SLOTS AVAILABLE HERE
})
return () => <div class="hello">{slots.default}</div>
}
}
The thing is, I need {slots.default} for render function / JSX inside setup(), so I can't use this.$slots.default either since "this" is not available in setup().
If I try to destruct context to { slots } then it even empty inside onMounted function
import { onMounted, createElement as h } from '@vue/composition-api'
export default {
name: 'HelloWorld',
props: {
msg: String
},
setup(props, { slots }) {
console.log(slots) // EMPTY OBJECT HERE
onMounted(() => {
console.log(slots) // ALSO EMPTY HERE
})
return () => <div class="hello">{slots.default}</div>
}
}