@@ -7,15 +7,6 @@ import { MAX_MESSAGE_TEXT_LENGTH } from "../../config";
7
7
import "./styles.css" ;
8
8
9
9
export const useText = initialText => {
10
- // TODO: extract useState logic out of MessageForm
11
-
12
- return {
13
- text,
14
- handleChange
15
- } ;
16
- } ;
17
-
18
- export const MessageForm = ( { user} ) => {
19
10
const [ text , setText ] = React . useState ( "" ) ;
20
11
21
12
const handleChange = event => {
@@ -24,20 +15,26 @@ export const MessageForm = ({ user }) => {
24
15
setText ( updatedText ) ;
25
16
} ;
26
17
18
+ return {
19
+ text,
20
+ handleChange
21
+ } ;
22
+ } ;
23
+
24
+ export const MessageForm = ( { user} ) => {
25
+ const { text, handleChange} = useText ( "" ) ;
27
26
return (
28
27
< Card className = "MessageForm" profile_image = { user . profile_image } >
29
28
< 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 >
41
38
< div className = "MessageForm_Options" >
42
39
< span className = "MessageForm_TextCount" title = "text-count" >
43
40
{ text . length } /{ MAX_MESSAGE_TEXT_LENGTH }