![](/img/trans.png)
[英]react-native-router-flux: implement animation in scene transition in react-native-router-flux
[英]react-native-router-flux: onLeft scene
我试图从场景返回时为场景employeeEdit场景添加onLeft,如果用户不希望更改当前选择的员工,他们将能够返回到员工列表,并且去时字段将被清空使用以下类型添加到“添加”:'reset',就好像要保存更改一样。
似乎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>
更长的方法。
使用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;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.