关注第一次onChange事件redux-form(filedarray)

时间:2017-05-01 14:36:34

标签: javascript reactjs redux redux-form

当我想写点东西时 - >使用redux-form(Field Arrays)首先关注onChange。 V6.5.0

带渲染的方法

const renderEmails = ({ fields, meta: { touched, error, submitFailed } }) => (
            <div className="col-xs-12">
                {fields.map((email, index) =>
                    <div key={index} className="fieldArray-container relative">
                        <div className="absolute-link left" style={indexStyle}>
                            {index + 1}
                        </div>
                        <button
                            type="button"
                            title="Remove rule"
                            className="btn btn-link absolute-link right"
                            style={removeButtonStyle}
                            onClick={() => fields.remove(index)}>
                            <i className="fa fa-times-circle" />
                        </button>
                        <Field
                            style={inputStyle}
                            name={`${email}.email`}
                            type="text"
                            component={Input}
                        />
                    </div>
                )}
                <div className="text-center"><button type="button" className="btn btn-link" onClick={() => fields.push({})}>+ Add Employee</button></div>
                {(touched || submitFailed) && error && <div className="alert alert-danger">{error}</div>}
            </div>
        );

调用fieldarray

<FieldArray name="employeeEmails" component={renderEmails} />

1 个答案:

答案 0 :(得分:0)