Skip to content

State nested in array not updating reactively? #713

Closed Answered by dai-shi
lkdm asked this question in Q&A
Discussion options

You must be logged in to vote
  set((state) => ({
    ...state,
    [_id] : {status: _value}
  })),

☝️ that should be something like this 👇 ?

  set((state) => {
    const services = [...state.services] // copy the array
    services[_id] = {status: _value}
    return { services }
  }),

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@lkdm
Comment options

@lkdm
Comment options

@dai-shi
Comment options

@lkdm
Comment options

Answer selected by lkdm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants