vite-plugin-vue icon indicating copy to clipboard operation
vite-plugin-vue copied to clipboard

Slots reactivity is not supported

Open PurpleTape opened this issue 2 years ago • 0 comments

Related plugins

Describe the bug

Sometimes there is a need to transfer a slot to the component, depending on the reactive value. In the syntax of SFC templates, this can be done as follows:

<template>
  <Comp>
    <template #slotName v-if="someReactiveVariable">
       Slot value
    </template>
  </Comp>
</template>

But when I try to do something like this in JSX, it lose the ability to reactively control the transfer of the slot to the component:

const render = () => (
  <Comp>
    {{
      slotName: someReactiveVariable.value ? () => 'Slot value' : undefined
    }}
  </Comp>
)

What to do in such a situation?

Reproduction

https://stackblitz.com/edit/vitejs-vite-t9skwh?file=src%2FApp.tsx

Steps to reproduce

Click "Toggle useSlot" button

System Info

"@vitejs/plugin-vue-jsx": "^3.0.2"

Used Package Manager

npm

Logs

No response

Validations

PurpleTape avatar Aug 26 '23 03:08 PurpleTape