从堆栈中弹出 Navigation on react-native-router-flux

Pop out from the stack Navigation on react-native-router-flux

这是我的Router navigation setup。我从 EmployeeList 导航到 EmployeeCreate 组件。我想在单击 Create 按钮时返回到 EmployeeList。

<Router>
   <Scene key="root" hideNavBar={true}>
     <Scene key="auth">
       <Scene key="login" component={LoginForm} title="Login" />
     </Scene>

     <Scene key="main">
      <Scene
        onRight={() => Actions.employeeCreate()}
        rightTitle="Add"
        key="employeeList"
        component={EmployeeList}
        title="Employee List"
        initial={true}
      />
      <Scene key="employeeCreate" component={EmployeeCreate} title="Employee Create"/>
     </Scene>
  </Scene>
</Router>

我试过这样。但是出现错误:

"There is no route defined for key employeeCreate. Must be one of: 'auth','main'"

Actions.employeeCreate({ type: 'reset' });

EmployeeCreate.js

onButtonPress() {
    const { name, phone, shift } = this.props;
   this.props.employeeCreate({name, phone, shift: shift || 'Monday'});
 }

export const employeeCreate = ({ name, phone, shift }) => {
  return() => {
    Actions.employeeCreate({ type: 'reset' });
  }
};

如何在主场景中调用employeeList场景?

要返回上一个组件,您应该使用

Actions.pop()

如果您需要转到您正在处理的场景组中存在的特定场景。您可以通过您在场景中定义的键调用场景

Actions.employeeList()

如果需要转到其他组场景需要调用父场景的key

Actions.auth()