Skip to content

Instantly share code, notes, and snippets.

@rodrigograca31
Last active December 2, 2019 14:57
Show Gist options
  • Save rodrigograca31/6a1920ca50312190918788beab5ddbce to your computer and use it in GitHub Desktop.
Save rodrigograca31/6a1920ca50312190918788beab5ddbce to your computer and use it in GitHub Desktop.
Find and edit in array with map
props.setMembers([
...props.members.map((el, index) => {
if (el.id == props.editThisOne.id) {
el = member;
}
return el;
})
]);
this.setState(oldState => ({
todos: [
...oldState.todos.map((el, index) => {
if (el.id == todo.id) {
// el = todo;
el.completed = true;
}
return el;
})
]
}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment