How can I go back to the last action in action-native for Android?
My thinking:
1 set _navigate to index.android.js
// ่ฎพ็ฝฎๅ้็ๅ ๆ var _navigator; BackAndroid.addEventListener('hardwareBackPress', function() { if (_navigator && _navigator.getCurrentRoutes().length > 1) { _navigator.pop(); return true; } return false; });
2 pass navigator in RouteMapping:
RouteMapper: function(route, navigationOperations, onComponentRef) { _navigator = navigationOperations; if (route.name === 'detail') { // ้ฎ้ข่ฏฆๆ
้กตreturn ( <DetailScreen navigator={navigationOperations} question={route.question} /> ); } else if (route.name == 'front') { // ้ฆ้กตreturn( <FrontScreen navigator={navigationOperations} /> ); } },
3 set the list view
gotoDetail: function(question: Object) { this.props.navigator.push({ id: question.question_id, name: 'detail', question: question })
But that does not work. When I click the back button in Android, does it jump out of the app?
How can i do this?
Or can someone give an example?
source share