rodrigograca31
12/2/2019 - 2:53 PM

Find and edit in array with map

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;
		})
	]
}));