Padavan
Padavan

Reputation: 103

Unlink state form store

I've had a problem

  data() {
    return {
      list: [],
      initState: { id: null, data: null }
    }
  },
  computed: {    
     ...mapState({
        contacts: (state) => state.ContactBook.Contacts
      })
     },},
      methods: {
        setinitState(payload) {
          this.initState.data = contacts[this.contactID]
        },

How Can I make this.initState static? I need this.initState didnt changes when contacts[this.contactID] changes...

Upvotes: 0

Views: 58

Answers (2)

Padavan
Padavan

Reputation: 103

state.snapshot = JSON.parse(JSON.stringify(state.Contacts[payload]))

Upvotes: 0

dsfx3d
dsfx3d

Reputation: 382

You may use the spread operator like this,

this.initState.data = {...contacts[this.contanctID]}

Spread Operator MDN

Upvotes: 1

Related Questions