0

這是我的Router navigation setup。我導航從EmployeeListEmployeeCreate組件。當我點擊創建按鈕時,我想回到EmployeeList。從堆棧彈出反應native-router-flux導航

<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' }); 

EmployeeCreateJS

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的場景主場景裏面?

+0

你能平安的關鍵你創建按鈕的代碼調用PLZ? –

+0

@GabrielDiez更新。請立即檢查 – Balasubramanian

+1

嘗試Actions.pop()返回到之前的組件 –

回答

1

對於回到以前的組件如果你需要去特定場景誰是目前集團您正在使用的場景中,你應該使用

Actions.pop() 

。你可以調用的關鍵場景在場景中

Actions.employeeList() 

定義。如果你需要去的另一組場景你必須調用父場景

Actions.auth()