我使用redux-form
和redux-form-material-ui
来创建一些简单的表单。 subdepartment
选择中的值取决于department
选择中选择的值。所以我创建了一个在department
选择的更改时触发的回调函数。获取subdepartment
选择的数据有效,但选择的值department
选择不再出现。
import React from 'react';
import { Field } from 'redux-form';
import { SelectField } from 'redux-form-material-ui';
import MenuItem from 'material-ui/MenuItem';
<Field
name={name}
component={SelectField}
hintText={label}
floatingLabelText={label}
onChange={callback}
>
{this.renderOptions(options)}
</Field>
回调:
searchSubdepartments: departmentId => dispatch(searchSubdepartments(departmentId))