Skip to content

Instantly share code, notes, and snippets.

@yhaskell
Last active April 29, 2017 13:50
Show Gist options
  • Save yhaskell/55b3b2ec62ed6d4f221d4b5921ba8487 to your computer and use it in GitHub Desktop.
Save yhaskell/55b3b2ec62ed6d4f221d4b5921ba8487 to your computer and use it in GitHub Desktop.
class PhoneList extends Component {
onRemovePhone(phone) {
fetch(`${this.props.apiUrl}/${phone.id}`, {
method: "delete",
credentials: "same-origin"
}).then(() => {
this.setState(state => ({ phones: state.phones.filter(p => p.id != phone.id) }))
})
//...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment