-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
useTemplateRef warning appears after rollup packaging #12852
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
Comments
You did not configure the |
Encountered with same warning but in usage of our UI kit. We have a layout component (VDefaultLayoutHeader) with code <script lang="ts" setup>
const refHeader = useTemplateRef('refHeader')
</script>
<template>
<header ref="refHeader" class="v-default-layout-header">
...
</header>
</template> Library is building without problems, but in project where we use this component console display warning message |
@yakudik Please provide a minimal reproduction. |
Thanks for the answer. The same warning happens when I bundle |
@yakudik minimal reproduction with playground, the warning will disappear after changing from DEV to PROD. |
@edison1105 Thanks for your answer. I solved my problem. |
It's true, this warning don't be showed in production, but the main problem is that we use templateRefs not only for VDefaultLayoutHeader. We also have VDataTableTr, for example. This component has two templateRefs (on checkbox and row action) And this component, as you imagine, generate hundreds and hundreds of wirnings during local development) |
<script lang="ts" setup>
-const refHeader = useTemplateRef('refHeader')
+const headerRef = useTemplateRef('refHeader') // use a diff var name is a workaround
</script>
<template>
<header ref="refHeader" class="v-default-layout-header">
...
</header>
</template> |
@edison1105 Is this a bug? Or is it my problem? |
@bee1an this is a bug but an edge case. |
@edison1105 Thank you. I look forward to your fixing it |
<script lang="ts" setup> -const refHeader = useTemplateRef('refHeader') +const headerRef = useTemplateRef('refHeader') // use a diff var name is a workaround </script> ... Yes, and this is my current temporary solution, but i'll of course wait for this problem to be fixed |
I think the real issue here is that in vue 3.5.13 in development mode, setting a template ref while having a variable with the same in the Minimum example: <script setup>
import {onMounted} from 'vue';
let div = null;
onMounted(() => console.log(div)); // div is not null but refers to the div node below
</script>
<template>
<div ref="div"></div>
</template> Console warning: A possible workaround is to name template ref using invalid identifier characters like |
Using the same variable name will trigger some warnings, see vuejs/core#12852
…me warning about "failing set operations on readonly target" (#3191) - added `no-shadow-template-ref` eslint rule to avoid Vue runtime warnings about "failing set operations on readonly target". This is a bug in vue, see vuejs/core#12852. The rule is redundant as soon as this is fixed by vue. - fix warning from `OnyxMoreList` - added test:eslint-plugins to `test:all` script, didn't seem to have been run before in the CI
…me warning about "failing set operations on readonly target" (#3191) - added `no-shadow-template-ref` eslint rule to avoid Vue runtime warnings about "failing set operations on readonly target". This is a bug in vue, see vuejs/core#12852. The rule is redundant as soon as this is fixed by vue. - fix warning from `OnyxMoreList` - added test:eslint-plugins to `test:all` script, didn't seem to have been run before in the CI
Hi, I'm encountering the same issue described in this PR (#13449) after migrating our component library to production builds. Our situation: After bundling with Vite, we're seeing consistent warnings in development mode: [Vue warn] Set operation on key "value" failed: target is readonly Due to the scale of usage, it's impractical for us to modify each instance Observations: Could you please share: Which Vue version will include the fix (v3.4.x or later?) Any recommended workarounds until the fix ships This is blocking our component library's production rollout. We'd be grateful for any updates on the release plan. Thank you for your work on this fix! |
Due to a Vue compiler bug, a template ref created through useTemplateRef may trigger a warning about mutating readonly refs in development mode of the applications using RIS UI. While this doesn't break anything, it adds a lot of noise to the console and test output. See: vuejs/core#12852
Version
3.5.13
Reproduction link
stackblitz.com
Steps to reproduce
When the useTemplateRef argument has the same name as the variable that received it, a console warning appears after using rollup
What is expected?
No warnings
What is actually happening?
[Vue warn] Set operation on key "value" failed: target is readonly.
The text was updated successfully, but these errors were encountered: