carlesba
carlesba

Reputation: 3156

How to update nested values with immutable.js

I have a structure like this one:

{
  members: [
    { memberId: 1, workspaces: [123, 124] },
    { memberId: 2, workspaces: [124] },
    ...
    ]
}

How could I update the workspace list for one member with Immutable.js?

Upvotes: 0

Views: 889

Answers (1)

carlesba
carlesba

Reputation: 3156

Found!

members.updateIn(
  ['0', 'workspaces'],
  (workspaces) => workspaces.push(125)
)

Upvotes: 2

Related Questions