나는 이것을 시도하고있다 :
"redux-form": "6.0.0-rc.5",
"react": "^15.3.1",
"react-dom": "^15.3.1",
addressUpdated(newAddress) {
//TODO, tell Redux form that a value is now available!
this.props.fields.address.onChange(newAddress.label);
}
address 는 addressUpdated가 호출되면 값을 가져와야하는 숨겨진 필드입니다. 오류가 발생합니다
Uncaught TypeError: Cannot read property 'onChange' of undefined
구성 요소가 생성됩니다.
<Field id="address" name="address" type="hidden" component={fieldFactory} />
const fieldFactory = ({id, input, label, type, meta: { touched, error } }) => {
if(type.match(/hidden/)){
return(
<div>
<input id={id} {...input} type={type} />
{touched && error && <span>{error}</span>}
</div>
);
}
}
```
어떤 아이디어?
내가 올바르게 이해하면 v6의 소품에서 더 이상 필드 를 사용할 수 없습니다 .
row-form.js를 고려하십시오.
Row.propTypes = {
change: PropTypes.func.isRequired, // this binds redux-form change action creator
dispatch: PropTypes.func.isRequired
}
콜백 함수는 다음과 같습니다.
addressUpdated(newAddress) {
this.props.dispatch(this.props.change('address', newAddress.label);
}
v6 rc5에서는 버그로 인해 작동하지 않지만 6.0.1에서 수정되었습니다.
rc5에서 작동하도록하려면 전역 변경 작업 작성자를 가져 와서 양식 이름으로 전달해야합니다.
import { change } from 'redux-form';
Row.propTypes = {
form: PropTypes.string.isRequired,
dispatch: PropTypes.func.isRequired
}
addressUpdated(newAddress) {
this.props.dispatch(change(this.props.form, 'address', newAddress.label);
}
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다