我正在尝试为场景employeeEdit场景添加重置,当用户从场景返回时,如果用户不希望对当前选定的员工进行更改,他们将能够返回到员工列表,并且当使用类型:‘onLeft’进行添加时,这些字段将被清空,就好像我们要保存更改一样。
在这种情况下,onLeft似乎不起作用,因为函数实际上并没有被执行。
<Router sceneStyle={{ paddingTop: 65 }}>
<Scene key="auth">
<Scene key="login" component={LoginForm} title="Please Login" initial />
</Scene>
<Scene key="main">
<Scene
onRight={() => Actions.employeeCreate()}
rightTitle="Add"
key="employeeList"
component={EmployeeList}
title="Employees"
initial
/>
<Scene
key="employeeCreate"
component={EmployeeCreate}
title="Create Employee"
/>
<Scene
onLeft={() => Actions.employeeList({ type: 'reset' })}
key="employeeEdit"
component={EmployeeEdit}
title="Edit Employee"
/>
</Scene>
</Router>发布于 2017-04-03 20:07:59
一种更长的方法。
使用componentWillUnmount时,这在离开组件(即EmployeeEdit )时非常有效
componentWillUnmount () {
this.props.employeeInitial();
}然后,这可以调用gigInitial的一个属性;具有一个将返回类型为“EMPLOYEE_INITIAL”的调度的操作。
export const employeeInitial = () => {
return (dispatch) => {
dispatch({ type: EMPLOYEE_INITIAL });
};
};,然后在EmployeeFormReducer中返回INITIAL_STATE。
case EMPLOYEE_INITIAL:
return INITIAL_STATE;https://stackoverflow.com/questions/43117362
复制相似问题