相关疑难解决方法(0)

如何以redux格式重置初始值

我正在使用redux-form.我在州的输入字段中显示初始值.当我单击重置时,输入字段仍显示初始值.

如何重置输入字段?

这是我的代码:

const mapStateToProps = (state) => {
    return {
        initialValues: {
            name:state.userInfo.data.name,
            email:state.userInfo.data.email,
            phone:state.userInfo.data.phone,
            city:state.userInfo.data.city.name,
        }
    };
}
Run Code Online (Sandbox Code Playgroud)

这就是我在输入字段中调用初始值的方法.

const renderField = ({ input, label, type, meta: { touched, error } }) => (
    <div>
        <input className="form-control control_new" {...input} placeholder={label} type={type}/>
    {touched && ((error && <span>{error}</span>))}
    </div>
)

<Field type="text" {...name} name="name" component={renderField} label="Enter Your Name" />
Run Code Online (Sandbox Code Playgroud)

谢谢

reactjs redux redux-form

18
推荐指数
3
解决办法
2万
查看次数

标签 统计

reactjs ×1

redux ×1

redux-form ×1