-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathCommentCreator.js
More file actions
45 lines (40 loc) · 1.06 KB
/
CommentCreator.js
File metadata and controls
45 lines (40 loc) · 1.06 KB
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
40
41
42
43
44
45
import React, { useState } from 'react';
import PropTypes from 'prop-types';
import styles from './CommentCreator.css';
function CommentCreator(props) {
const [name, setName] = useState('');
const [text, setText] = useState('');
const addComment = () => {
props.handleAdd(props.post, name, text);
setName('');
setText('');
};
return (
<div className={`${styles['creator-container']}`}>
<h4>What do you think about it? Let's text</h4>
<div className={`${styles['input-area']}`}>
<input
placeholder="Name"
onChange={e => setName(e.target.value)}
value={name}
/>
<textarea
placeholder="Message"
onChange={e => setText(e.target.value)}
value={text}
/>
</div>
<button
className={`${styles['btn-send']}`}
onClick={() => addComment()}
>
Send
</button>
</div>
);
}
CommentCreator.propTypes = {
handleAdd: PropTypes.func.isRequired,
post: PropTypes.string.isRequired,
};
export default CommentCreator;