Last active
August 3, 2020 15:56
-
-
Save jaunesarmiento/9e4cf946ee39c3cf4b3d54267b8d964b to your computer and use it in GitHub Desktop.
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
const [messageBody, setMessageBody] = useState(''); | |
// useEffect(...) for loading initial messages | |
// useEffect(...) for subscriptions | |
const handleChange = (event) => { | |
setMessageBody(event.target.value); | |
}; | |
const handleSubmit = async (event) => { | |
event.preventDefault(); | |
event.stopPropagation(); | |
const input = { | |
channelID: '1', | |
author: 'Dave', | |
body: messageBody.trim() | |
}; | |
try { | |
setMessageBody(''); | |
await API.graphql(graphqlOperation(createMessage, { input })) | |
} catch (error) { | |
console.warn(error); | |
} | |
}; | |
// return (...) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment