Skip to content

Instantly share code, notes, and snippets.

@minmaxdata
Last active August 4, 2018 22:38
Show Gist options
  • Save minmaxdata/8eac441f9d5371aa1b65985d92a61282 to your computer and use it in GitHub Desktop.
Save minmaxdata/8eac441f9d5371aa1b65985d92a61282 to your computer and use it in GitHub Desktop.
examples of the use of the spread operator
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