admin管理员组文章数量:1328034
I have 3 screen on a StackNavigator : MainSearch
, MonsterPage
, ItemPage
.
And I want to stack MonsterPage
and ItemPage
multiple times (from MonsterPage
you can go to ItemPage
and vice versa)
Is possible to instantiate the screens?
const AppNavigator = createStackNavigator(
{
Home: MainSearch,
MonsterPage: MonsterPage,
ItemPage: ItemPage
},
{
initialRouteName: "Home"
}
);
export default createAppContainer(AppNavigator);
What I want:
MainSearch -> ItemPage(1) -> MonsterPage(1) -> ItemPage(2) -> etc...
or
MainSearch -> MonsterPage(1) -> ItemPage(1) -> MonsterPage(2) -> etc...
What I get:
MainSearch -> MonsterPage(1) -> ItemPage(1) ->(goes back to) MonsterPage(1)
Gif showing what happens
MainSearch
onPress={() => { this.props.navigation.navigate(`${r._source.super_cat === 'monster' ? 'MonsterPage' : 'ItemPage'}`, { item: r._source }) }}
MonsterPage
onPress={() => { this.props.navigation.navigate('ItemPage', { item: {id: drop.item_id, NameZh_ragmobile: drop.item_name_EN, super_cat: 'item'} }) }
ItemPage
onPress={() => { this.props.navigation.navigate('MonsterPage', { item: {id: mob.mob_id, NameZh_ragmobile: mob.mob_name_EN, super_cat: 'monster'} }) }
I have 3 screen on a StackNavigator : MainSearch
, MonsterPage
, ItemPage
.
And I want to stack MonsterPage
and ItemPage
multiple times (from MonsterPage
you can go to ItemPage
and vice versa)
Is possible to instantiate the screens?
const AppNavigator = createStackNavigator(
{
Home: MainSearch,
MonsterPage: MonsterPage,
ItemPage: ItemPage
},
{
initialRouteName: "Home"
}
);
export default createAppContainer(AppNavigator);
What I want:
MainSearch -> ItemPage(1) -> MonsterPage(1) -> ItemPage(2) -> etc...
or
MainSearch -> MonsterPage(1) -> ItemPage(1) -> MonsterPage(2) -> etc...
What I get:
MainSearch -> MonsterPage(1) -> ItemPage(1) ->(goes back to) MonsterPage(1)
Gif showing what happens
MainSearch
onPress={() => { this.props.navigation.navigate(`${r._source.super_cat === 'monster' ? 'MonsterPage' : 'ItemPage'}`, { item: r._source }) }}
MonsterPage
onPress={() => { this.props.navigation.navigate('ItemPage', { item: {id: drop.item_id, NameZh_ragmobile: drop.item_name_EN, super_cat: 'item'} }) }
ItemPage
onPress={() => { this.props.navigation.navigate('MonsterPage', { item: {id: mob.mob_id, NameZh_ragmobile: mob.mob_name_EN, super_cat: 'monster'} }) }
Share
Improve this question
edited Jun 20, 2020 at 9:12
CommunityBot
11 silver badge
asked Mar 17, 2019 at 19:56
Guilherme FagaGuilherme Faga
1481 silver badge8 bronze badges
2 Answers
Reset to default 11I got it... just change this.props.navigation.navigate(...)
to this.props.navigation.push(...)
In addition to the accepted answer, maybe check your import path too so that you are not pointing to the same screen multiple times like shown below.
import CategoriesScreen from './screens/CategoriesScreen' <--- Same
import MealsScreen from './screens/CategoriesScreen' <--- Path
本文标签: javascriptStack same screen multiple times with React NavigationStack Overflow
版权声明:本文标题:javascript - Stack same screen multiple times with React Navigation - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742244894a2439066.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论