スタイル付きコンポーネントと一緒に Redux Form を使用しています。
Redux Form Field の参照を取得したいので、特定の条件に集中できます。
コードは次のようになります: (少し簡略化)
export const SomeForm = () => (
<form onSubmit={handleSubmit} >
<FormLabel htmlFor="comment">Comment:</FormLabel>
<CommentTextArea
name="comment"
component="textArea"
maxLength="250"
innerRef={commentBox => this.commentBox = commentBox}
/>
</form>
);
は次のCommentTextArea
ようなスタイルのコンポーネントです。
const CommentTextArea = styled(Field)`
background-color: grey;
border-radius: 3px;
color: black;
height: 6.5rem;
margin-bottom: 1rem;
`;
問題は、innerRef
のthis
値が定義されていないことです。の参照にアクセスして、textArea
必要に応じてフォーカスする方法はありますか?
(FormLabel
スタイル付きのコンポーネントでもありますが、問題のために表示する必要はありません)
前もって感謝します。