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

Glitch when update nested reactive property #1366

Closed
CesarGomezTissini opened this issue Feb 21, 2021 · 4 comments
Closed

Glitch when update nested reactive property #1366

CesarGomezTissini opened this issue Feb 21, 2021 · 4 comments

Comments

@CesarGomezTissini
Copy link

CesarGomezTissini commented Feb 21, 2021

Version

6.0.0-beta.7

Browser and OS info

Microsoft Edge 88.0.705.74 / Windows 10

Steps to reproduce

  1. Create a composable function (useTest in my case), and set the following:
export default function useTest() {
  const state = reactive({
    load: reactive({
      number: 1,
    }),
    number: 1,
  });

  const changeNumber = () => {
    state.load.number = state.load.number   1;
  };

  return { ...toRefs(state), name, changeNumber };
  1. Import it and destructuring all its properties and methods into a component, for example, HelloWorld.vue.
<template>
  <button>{{ load.active }}</button>
  <button @click="changeNumber">World</button>
  <button @click="name">Change</button>
</template>
<script>
import { defineComponent } from "vue";
import useTest from "./../composables/useTest";

export default defineComponent({
  setup() {
    const { load, changeNumber, name } = useTest();

    return { load, changeNumber, name };
  },
});
</script>
  1. Set changeNumber to a button, and press.

What is expected?

state.load.number changing its value in Devtool automatically.

What is actually happening?

Not changes. I just should to press in parent component (App) and then in the child itself at Component tree view to see value update. This happened if property is not called in template, look like.

Additionally, "number" load sibling property isn't being showing in. I don't know if it's the same due to explained above (property is not called in Template)

I have generated the project with Vite.

@Akryum
Copy link
Member

Akryum commented Feb 21, 2021

Please provide a runnable reproduction thanks!

@CesarGomezTissini
Copy link
Author

CesarGomezTissini commented Feb 23, 2021

Please provide a runnable reproduction thanks!

Hey @Akryum. Sure, This is the link, just clone it: https://github.com/CesarGomezTissini/devtool-beta-repro

Regards!

@iraklisg
Copy link

Same problem for me running on Firefox 88.0b4 (64-bit) (Manjaro Linux)

@Akryum Akryum added the wontfix label May 6, 2021
@Akryum
Copy link
Member

Akryum commented May 6, 2021

@CesarGomezTissini If a reactive state isn't used in the application, it's not made reactive by Vue, and thus not triggering an update in your application nor in the devtools. Vue reactivity system is lazy.

In your reproduction, display load.number for example to make it reactive:

<button>{{ load.active }} {{ load.number }}</button>

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

No branches or pull requests

3 participants