The objective is to reuse the same screen ui with different content and still be able to handle back navigation(like how reddit app can show multiple user/feed screens as you click on them but still handle custom back navigation) using react native navigation v2?
trying to use dynamic screen id's and use them in state variables. I haven't come very far with this approach.
The inbuilt back button handles back navigation but consider the scenario as follows:
I am working on a form and I open another form, work on it, save it and have to return to the existing form. custom handlers do not allow it.
CODE:
HomeScreen:
Navigation.push(this.props.componentId, {
component: {
name: 'example.formScreen',
passProps: {
data: some props
},
options: {
topBar: {
title: {
text: 'form Screen'
}
}
}
}
});
in form screen:
<View>
<Button
title="save form"
onpress = ()=>{
Navigation.push(this.props.componentId, {
component: {
name: 'example.formScreen',
passProps: {
data: some other props
},
options: {
topBar: {
title: {
text: 'form Screen'
}
}
}
}
});
}/>
<Button
title="go back"
onPress={()=>Navigation.pop(this.props.componentID)}
/>
</View>