Skip to content
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

fix: TypeError: 0 is read-only #768

Open
MariusE opened this issue Jan 5, 2025 · 0 comments
Open

fix: TypeError: 0 is read-only #768

MariusE opened this issue Jan 5, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@MariusE
Copy link

MariusE commented Jan 5, 2025

🐛 The bug

When I use useState in combination with v-model and reload the page with DevTools 'Payload' opened, the console get's logged full with error TypeError: 0 is read-only per tick. This also seems to be triggered when changing a value.

Image

Below a simplified example:

Steps:

  1. Open Link below
  2. Open Nuxt DevTools
  3. Go to 'Payload' page in Nuxt DevTools
  4. Open Firefox DevTools on Console
  5. Change selected Value
  6. ➡ Error is logged

The repeated errors could not be reproduced on StackBlitz. Hard-Reloading the page is also not possible with StackBlitz. So it's only reproducable on value-change.


It took me a while to figure out, that the error is propably caused by Nuxt DevTools and not my own code. So, hopefully I did not overlook anythink.

🛠️ To reproduce

https://stackblitz.com/edit/nuxt-devtools-yry9cp9b?file=app.vue

🌈 Expected behavior

No error when changing state with DevTools opened.

ℹ️ Additional context

Example component:

<script setup lang="ts">
const role = useState('role', () => 'manager')

const c = () => {
  console.info('Role changed to:', role.value)
}
</script>

<template>
  <div>
    <label for="role-select">Select Role:</label>
    <select @change="c" id="role-select" v-model="role">
      <option value="manager">Manager</option>
      <option value="admin">Admin</option>
      <option value="user">User</option>
    </select>
    <p>Selected Role: {{ role }}</p>
  </div>
</template>
@MariusE MariusE added the bug Something isn't working label Jan 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant