Ref returned from composition outside of script setup no longer works after version 3.2.8
Version
3.2.11
Reproduction link
Steps to reproduce
- In SFC Playground, open the console;
- Click on "Hello" div.
What is expected?
It should appear in the console "clicked" and then "has value".
What is actually happening?
Only "clicked" appears .
In dev this works normally, but in build the container.value
in useSomething
remains null
. Before version 3.2.8 it worked in both dev and build. I believe it may be related to https://github.com/vuejs/vue-next/pull/4492
As a workaround, wrap the container ref, it will be the same ref but the compiler will generate the appropriate code:
<script setup>
import {ref } from 'vue'
import { useSomething } from "./composition.js"
const { container, handleClick } = useSomething()
const el = ref(container)
</script>
<template>
<div ref="el" @click="handleClick">
Hello
</div>
</template>