Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Old Code
- const newMap = e.props.map;
- let arr = this.state.maps;
- let i = 0;
- let found = false;
- while (!found && i < arr.length) {
- found = arr[i].name === newMap.name;
- i++;
- }
- if (found) {
- arr[i - 1].completed = !arr[i - 1].completed;
- }
- this.setState({
- maps: arr
- });
- // New Code
- const items = this.state.maps;
- changedMaps.forEach(map => {
- const i = items.map(m => m.name).indexOf(map.name);
- items[i].completed = !items[i].completed;
- });
- this.setState({ items });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement