0

スタイル付きコンポーネントと一緒に 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;
`;

問題は、innerRefthis値が定義されていないことです。の参照にアクセスして、textArea必要に応じてフォーカスする方法はありますか?

(FormLabelスタイル付きのコンポーネントでもありますが、問題のために表示する必要はありません)

前もって感謝します。

4

1 に答える 1