Skip to content

Commit 1b181b5

Browse files
committed
Rename props in CommentForm.js
1 parent 0f4668f commit 1b181b5

File tree

2 files changed

+10
-23
lines changed

2 files changed

+10
-23
lines changed

src/components/CommentForm.js

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,9 @@ import FormError from './FormError'
66
import MediaPreview from './MediaPreview'
77

88
const CommentForm = (props) => {
9-
const {
10-
attachments,
11-
setAttachments,
12-
addCommentReply,
13-
commentReply,
14-
setCommentReply
15-
} = props
9+
const { attachments, setAttachments, addComment, comment, setComment } = props
1610

17-
const {
18-
register: registerReply,
19-
errors: errorsReply,
20-
handleSubmit: handleSubmitReply
21-
} = useForm()
11+
const { register, errors, handleSubmit } = useForm()
2212

2313
const handleFileChange = async (event) => {
2414
const newFiles = event.target.files
@@ -34,18 +24,15 @@ const CommentForm = (props) => {
3424
}
3525

3626
return (
37-
<form
38-
className='comment-form'
39-
onSubmit={handleSubmitReply(addCommentReply)}
40-
>
27+
<form className='comment-form' onSubmit={handleSubmit(addComment)}>
4128
<div className='comment-input'>
4229
<textarea
4330
rows='5'
4431
cols='25'
4532
name='Comments'
46-
ref={registerReply({ required: true })}
47-
value={commentReply}
48-
onChange={(e) => setCommentReply(e.target.value)}
33+
value={comment}
34+
ref={register({ required: true })}
35+
onChange={(e) => setComment(e.target.value)}
4936
></textarea>
5037
<div className='file-input'>
5138
<input
@@ -60,7 +47,7 @@ const CommentForm = (props) => {
6047
</label>
6148
</div>
6249
</div>
63-
{errorsReply.Comments && <FormError message='Reply cannot be empty' />}
50+
{errors.Comments && <FormError message='Reply cannot be empty' />}
6451
<MediaPreview attachments={attachments} setAttachments={setAttachments} />
6552
<Button className='btn btn-default'>Add Reply</Button>
6653
</form>

src/components/Comments.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,9 @@ const Comments = (props) => {
195195
<CommentForm
196196
attachments={attachments}
197197
setAttachments={setAttachments}
198-
addCommentReply={addCommentReply}
199-
commentReply={commentReply}
200-
setCommentReply={setCommentReply}
198+
addComment={addCommentReply}
199+
comment={commentReply}
200+
setComment={setCommentReply}
201201
/>
202202
)}
203203
</div>

0 commit comments

Comments
 (0)