Reputation: 1227
There is any way to get the current screen?
I have my first (main) screen doing a bunch of things in background, like searching beacons. And every time I find one of my beacons I want to navigate to the screen that shows info about that beacon.
The problem is that, I'll keep pushing screens every time I get a new beacon found and I do not want that. If I'm in the detailScreen I want to replace the screen with the new data.
I want something like that:
if (navigation.currentScreen == 'Homepage' || navigation.currentScreen == 'Monument') {
navigate('MonumentDetails', {monumento:i, poi:j, description_types:this.state.data.categories, data:this.state.data});
} else {
replace('MonumentDetails', {monumento:i, poi:j, description_types:this.state.data.categories, data:this.state.data});
}
I know that there is no navigation.currentScreen
, but is just to explain you what I want.
Hope you can help me! Thank you!
Upvotes: 4
Views: 1103
Reputation: 1421
You can try using navigate() with a key to keep only a single detail screen. Or you could replace the stack using replace()
navigate({
routeName: 'MonumentDetails',
params: {
monumento:i,
poi:j,
description_types:this.state.data.categories,
data:this.state.data
},
key: 'detail',
});
Upvotes: 1