이전에 Redux-Form V5에서 render 함수 내부에서 email.error
및 password.error
이라는 오류에 액세스했습니다. V7에서reduxForm V7이있는 컨테이너 내부에서 redux-form 오류에 액세스하는 방법이 있습니까?
, 내 CSS 나에게 그것을 이런 식으로 할 슬픔을주고있다 : 나는 오류를 렌더링하는 경우 renderInput()
를 통해
const renderInput = (field) => {
const { meta: { touched, error } } = field
return (
<div>
<input type={field.type} placeholder={field.placeholder} {...field.input} />
<div className="inputErrorText">
{touched ? error : ''} // this doesnt work due to my CSS
</div>
</div>
)
}
// ...inside the Container:
<div className="ui left icon input">
<i className="user icon"></i>
<Field
name="email"
component={renderInput}
type="text"
placeholder="Enter your Email"
/>
</div>
// Below is the old way I was doing it
{/*email.touched && email.error && <div className="inputErrorText">{email.error}</div>*/}
을의 CSS는, 때문에 어떤 위치의 상대 + 절대 이유의 모습에 엉망이됩니다 그래서 위의 코드 하단에있는 마지막 div 아래에 렌더링 오류가 필요합니다.
필드 오류를 renderInput()
및/또는 <form>
외부로 렌더링하는 방법을 어떻게 다룰 수 있습니까? 제 질문은 field
입력 매개 변수 renderInput()
에 집중되어 있다고 생각합니다. 컨테이너 내부에서 어떻게 액세스 할 수 있습니까? 어디서나 this.props
에서 사용할 수 있습니까?
나는이 대답을 잠시 동안 "대답하지 않음"으로 남겨두고 있습니다. 방금이 예제를 다시 방문 했으므로 추가로 숙련 된 응답을 얻으면서 이제는 응답이 "상태를"첫 번째 공통 조상, 즉이 양식이 들어있는 컨테이너로 옮겨야한다고 생각합니다. – agm1984