2

我需要的是一件简单的事情。如果我选择国家,它应该设置电话前缀字段值。我有 2 个字段的 redux-form,我将 react-select 作为组件传递。

const BasicForm = props => {
const { error, handleSubmit, pristine, reset, submitting, countries, phonePrefixes } = props;
return (
        <div className="form step1">
            <form onSubmit={handleSubmit}>
                <Field
                    name="country"
                    className="form-control"
                    component={selectInput}
                    options={countries}
                    placeholder="Country"
                />
                <Field
                    name="phonePrefix"
                    className="form-control"
                    component={selectInput}
                    options={phonePrefixes}
                    placeholder="Prefix"
                />

                <button type="submit" disabled={submitting}>REGISTER
                    <i className="fa fa-chevron-right">&nbsp;</i>
                </button>
            </form>
        </div>
)};
4

1 回答 1

0

由于 redux-form 6.8 reduxForm() 装饰器支持 onChange处理程序,可以访问valuespropsdispatch这使您能够链接自定义逻辑查看更多:https ://redux-form.com/6.8.0/docs/api/ reduxform.md/

于 2020-02-26T13:54:12.940 回答