1
我無法正確使用NavigationActions.init()
或文檔中提到的狀態生成狀態。 這是怎麼我的導航儀定義:將導航路徑狀態設爲有密鑰和索引
const HomeNav = TabNavigator({
feed:{screen:Feed},
restaurantScreen:{screen:Restaurant},
},{
tabBarComponent:NavigationComponent,
tabBarPosition:'bottom',
tabBarOptions:{
bottomNavigationOptions:{
labelColor:'white',
rippleColor:'white',
tabs:{
feed:{
barBackgroundColor:'#37474F',
},
restaurantScreen:{
barBackgroundColor:'#00796B',
}
}
}
}
});
export const Navigator=StackNavigator(
{
HomeScreen:{screen:Home},
VerifyScreen:{screen:Verify},
newUserScreen1:{screen:newUser1},
newUserScreen2:{screen:newUser2},
loginScreen:{screen:login},
feedScreen:{screen:HomeNav},
},
{
headerMode:'none',
},
);
這是我怎麼設置我的初始狀態:
const initialState=Navigator.router.getStateForAction(
NavigationActions.init()
);
function navigate(screenName,state){
return Navigator.router.getStateForAction(NavigationActions.navigate({routeName:screenName},state));
}
以下錯誤顯示出來: Expect nav state to have routes and index,{routeName:'feedScreen',key:...}
當導航到飼料標籤導航儀。