-
Notifications
You must be signed in to change notification settings - Fork 109
/
Copy pathCreatePost.js
39 lines (32 loc) · 1.11 KB
/
CreatePost.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import React, { useState } from 'react';
import './CreatePost.css';
const CreatePost = () => {
const [post, setPost] = useState({title: "", author: "", description: ""})
const handleChange = (event) => {
const {name, value} = event.target;
setPost( (prev) => {
return {
...prev,
[name]:value,
}
})
}
return (
<div>
<form>
<label for="title">Title</label> <br />
<input type="text" id="title" name="title" onChange={handleChange} /><br />
<br/>
<label for="author">Author</label><br />
<input type="text" id="author" name="author" onChange={handleChange} /><br />
<br/>
<label for="description">Description</label><br />
<textarea rows="5" cols="50" id="description" name="description" onChange={handleChange}>
</textarea>
<br/>
<input type="submit" value="Submit" />
</form>
</div>
)
}
export default CreatePost