Last active
August 4, 2018 22:38
-
-
Save minmaxdata/8eac441f9d5371aa1b65985d92a61282 to your computer and use it in GitHub Desktop.
examples of the use of the spread operator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case TOGGLE_TWEET: | |
return { | |
...state, | |
[action.id]: { | |
...state[action.id], | |
likes: action.hasLiked === true | |
? state[action.id].likes.filter( (uid) => uid !== action.authedUser ) | |
: state[action.id].likes.concat([action.authedUser]) | |
} | |
} | |
const deck = { | |
...this.state.deck, | |
questions: [...this.state.deck.questions, { question, answer }] | |
}; | |
deletePost = (id) => { | |
this.setState({ | |
posts: { | |
...this.state.posts, | |
[id] : { | |
...this.state.posts[id], | |
deleted: true | |
} | |
} | |
}) | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment