5
I am using Vuex to manage the states of my app and I am creating a forward button and a back, in case of my advance I use the function below:
addUser() {
const payload = {
name: this.name,
email: this.email
};
this.$store.commit("CHANGE_USER", payload);
}
But I was in doubt on the back button, should I commit to an empty variable? Is it possible to go back to a "previous state"? That’s the right way?
You can try to store the user’s current value in the component, if you click forward you commit it to the store and if it comes back you do nothing and leave the value that was already in the store. Works for you?
– Thyago Dias