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

DevTools: Undefined value for oldValue in mutation event using Setup Stores #2061

Open
lombervid opened this issue Mar 8, 2023 · 1 comment · May be fixed by vuejs/core#8210
Open

DevTools: Undefined value for oldValue in mutation event using Setup Stores #2061

lombervid opened this issue Mar 8, 2023 · 1 comment · May be fixed by vuejs/core#8210

Comments

@lombervid
Copy link

lombervid commented Mar 8, 2023

Reproduction

https://codesandbox.io/p/sandbox/cocky-butterfly-51pk2y?file=%2Fsrc%2Fstores%2Fcounter.js

Steps to reproduce the bug

  1. Click counter button
  2. Check the mutation event on the Timeline tab in DevTools

Expected behavior

oldValue shows the previous value.

Actual behavior

oldValue shows an undefined value.

Additional information

Hello.

When I try using Setup Stores, the field oldValue is shown as undefined in the mutation event. But if I use Option Stores it shows the value correctly.

I have a code like this:
App.vue

<script setup>
import { useCounterStore } from "./stores/counter";

const counter = useCounterStore();
</script>

<template>
  <div class="card">
    <button type="button" @click="counter.increment()">
      count is {{ counter.count }}
    </button>
  </div>
</template>

Setup Stores: stores/counter.js

import { defineStore } from "pinia";
import { ref } from "vue";

export const useCounterStore = defineStore("counter", () => {
  const count = ref(0);

  function increment() {
    if (count.value < 10) {
      count.value++;
    }
  }

  return { count, increment };
});

Setup Store

Option Stores: stores/counter.js

import { defineStore } from "pinia";

export const useCounterStore = defineStore("counter", {
  state: () => ({
    count: 0,
  }),
  actions: {
    increment() {
      if (this.count < 10) {
        this.count++;
      }
    },
  },
});

Options Store

Regards!

@lombervid lombervid changed the title DevTools: Undefined value for oldValue in mutation event using Setup Stores DevTools: Undefined value for oldValue in mutation event using Setup Stores Mar 8, 2023
@sandexplus
Copy link

hi. any news? i have same problem with my Vue 3 project. Tried 2.0.32 - 2.0.34

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants