【发布时间】:2017-06-02 02:33:25
【问题描述】:
我正在使用 redux 表单,在加载组件时,我从 api 响应中获取我的文本字段的值,当我填充并提交这些值时,因为我没有触及这些字段 - 我看到验证错误 -就像它们是空的 - 如何将这些现有值传递给道具?
const emailValfromapi = this.props.data && this.props.data.email ? this.props.data.email : [];
const { handleSubmit, fields: { email, abc, def, etc } } = this.props;
<fieldset className="form-group">
<div className="input-wrapper">
<input value={emailValfromapi} id="email" {...email} type="email" className={email.touched && email.error ? 'error-red' : ''} required />
<label className="input-label" htmlFor="Email">To</label>
{ email.touched && email.error && <div className="alert-danger"> { email.error } </div> }
</div>
</fieldset>
【问题讨论】:
标签: reactjs react-jsx redux-form