Skip to content

Instantly share code, notes, and snippets.

@amandeepmittal
Created April 19, 2019 19:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amandeepmittal/60f8b8f110ebe95e427592e086c6d480 to your computer and use it in GitHub Desktop.
Save amandeepmittal/60f8b8f110ebe95e427592e086c6d480 to your computer and use it in GitHub Desktop.
// App.js
// ...
import { createNote, deleteNote } from "./graphql/mutations"
// inside App component, add this
deleteNote = async noteID => {
const { notes } = this.state
const input = { id: noteID }
const result = await API.graphql(graphqlOperation(deleteNote, { input }))
const deleteNoteId = result.data.deleteNote.id
const updatedNotesList = notes.filter(note => note.id !== deleteNoteId)
this.setState({ notes: updatedNotesList })
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment