Reactivity removed on refresh
See original GitHub issueI am having trouble with my store elements not continuing to be reactive after refreshing the page. My state to start is empty such that:
const state = {
items: [],
};
I then am using axios to get information from an API and then pushing objects into this array. Below is my mutation:
loadData(state, response) {
response.items.forEach(function(item) {
state.items.push(item);
});
// Vue.set(state, 'items', response.items);
},
When I inspect this property in the console, I can see that the reactive getters and setters are added onto these objects within the array. However, when I refresh the page and inspect these objects, the array is reactive but the actual objects are not.
How can I fix this without having to manually go through and fix this on every single module? (I tried to do a global Vue.set() on the state, but that didn’t fix it either.)
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (3 by maintainers)
Top Results From Across the Web
Vuex State not Reactive without Page reload - Stack Overflow
I have played around with async and await by removing them and adding them on certain places. I have used the $nextTick function...
Read more >"Forcing" a reactive to rerun - Google Groups
In the app I'm working on, I have a 'reactive' (r) that pulls data from a data base which is used in multiple...
Read more >Advanced Svelte: Reactivity, lifecycle, accessibility
We will learn how to deal with reactivity issues related to updating ... MoreActions : Displays the Check All and Remove Completed buttons, ......
Read more >[OutSystems Data Grid] Data Grid Reactive
In DataGrid Reactive, when I try to remove the row by clicking Remove Row it gets removed. But, when I refresh the screen...
Read more >Reactivity in Depth - Vue.js
When you assign or destructure a reactive object's property to a local variable, the reactivity is "disconnected" because access to the local variable...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I had the same issue but I wasn’t able to find a working solution so I decided to switch to Vuex-persistedstate which does not have this issue and provides almost the same functionalities as this package.
For anybody that is struggling with this same issue, I just implemented a quick recursive function that solves this solution for now. This is basically a hack so I am hoping that there is a better way to overcome this.
Just call the action as the first thing on the load of the page.