Skip to content

Instantly share code, notes, and snippets.

@greaveselliott
Last active June 23, 2019 21:04
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 greaveselliott/f8e9c3d606205d0d31089782ef8636a5 to your computer and use it in GitHub Desktop.
Save greaveselliott/f8e9c3d606205d0d31089782ef8636a5 to your computer and use it in GitHub Desktop.
import { createNewListItem } from "./Actions";
const { state, dispatch } = useContext(Store);
const input = useRef();
const onFormSubmit = event => {
event.preventDefault();
createNewListItem({
dispatch,
payload: { listItemValue: input.current.value }
});
};
return (
<main>
<h1>To do list</h1>
<form onSubmit={onFormSubmit}>
<input type="text" ref={input} />
<input type="submit"/>
</form>
// ...
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment