Created
October 2, 2019 14:41
-
-
Save cziem/0beb1d0104b5ca9493c0b42d6df09c3a to your computer and use it in GitHub Desktop.
Add a new post
This file contains hidden or 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
import React, { useQuery } from "react"; | |
const AddPost = () => { | |
const [postState, setPostState] = useQuery({ | |
title: "", | |
body: "" | |
}); | |
const handleChange = e => { | |
setPostState({ [e.target.name]: e.target.value }); | |
}; | |
return ( | |
<div> | |
<form> | |
<input | |
type="text" | |
value={postState.title} | |
name="title" | |
onChange={handleChange} | |
/> | |
<br /> | |
<input | |
type="text" | |
value={postState.body} | |
name="body" | |
onChange={handleChange} | |
/> | |
<br /> | |
<button>Publish</button> | |
</form> | |
</div> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment