Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit451a5de

Browse files
committed
solution: useText hook refactor
1 parent71deafa commit451a5de

File tree

1 file changed

+17
-20
lines changed

1 file changed

+17
-20
lines changed

‎src/components/MessageForm/index.js

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,6 @@ import { MAX_MESSAGE_TEXT_LENGTH } from "../../config";
77
import"./styles.css";
88

99
exportconstuseText=initialText=>{
10-
// TODO: extract useState logic out of MessageForm
11-
12-
return{
13-
text,
14-
handleChange
15-
};
16-
};
17-
18-
exportconstMessageForm=({ user})=>{
1910
const[text,setText]=React.useState("");
2011

2112
consthandleChange=event=>{
@@ -24,20 +15,26 @@ export const MessageForm = ({ user }) => {
2415
setText(updatedText);
2516
};
2617

18+
return{
19+
text,
20+
handleChange
21+
};
22+
};
23+
24+
exportconstMessageForm=({ user})=>{
25+
const{ text, handleChange}=useText("");
2726
return(
2827
<CardclassName="MessageForm"profile_image={user.profile_image}>
2928
<Form>
30-
<Form.Group>
31-
<Form.Control
32-
className="MessageForm_TextArea"
33-
aria-label="message-form"
34-
as="textarea"
35-
rows="3"
36-
placeholder="What's happening?"
37-
value={text}
38-
onChange={handleChange}
39-
/>
40-
</Form.Group>
29+
<Form.Group
30+
className="MessageForm_TextArea"
31+
aria-label="message-form"
32+
as="textarea"
33+
rows="3"
34+
placeholder="What's happening?"
35+
value={text}
36+
onChange={handleChange}
37+
></Form.Group>
4138
<divclassName="MessageForm_Options">
4239
<spanclassName="MessageForm_TextCount"title="text-count">
4340
{text.length} /{MAX_MESSAGE_TEXT_LENGTH}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp