back key can't lead the homeScreen to finish
I have an android activity,when I click a button, it go to the react native activity contains a home screen; I have override the onBackPressed method in react native activity likes below: if(mReactInstanceManager != null){ mReactInstanceManager.onBackPressed(); return; } super.onBackPressed();
In the ListComponent or DetailsComponent , I can click the back key to go back. However, in the home screen, when I click the back key; It can't finish this screen; I don't know why? Thanks for your attention!
My App.js is like below: export default class App extends React.Component{ render(){ return RootStack/>; }}
class HomeScreen extends React.Component{ constructor(props){ super(props); }
static navigationOptions = {
title: 'Welcome',
};
render(){
return(
<View style={{flex: 1, alignItems: 'center', justifyContent: 'center'}}>
<Text style={{padding: 15}}>Home Screen</Text>
<Button
title="Go to next"
onPress={this._gotoNext}
/>
</View>
);
}
_gotoNext = () => {
this.props.navigation.navigate('Next', {id: '100', 'title': 'Home Screen'})
};
}
const RootStack = StackNavigator({ Home:{ screen: HomeScreen, }, Next:{ screen: ListComponent, }, Detail:{ screen: DetailsComponent, }, }, { initialRouteName: 'Home', } );