I am working on an app but goback button is not taking me to the back screen.
App.js
import React, { Component } from 'react';
import one from './components/test/one';
import two from './components/test/two';
import three from './components/test/three';
import { DrawerNavigator } from 'react-navigation';
const AppNavigator = DrawerNavigator({
one: {
screen: one,
},
two: {
screen: two,
},
three: {
screen: three,
},
}
);
export default () =>
<AppNavigator />;
components/test/one.js
import React, { Component } from 'react';
import { Button } from 'react-native';
export default class one extends React.Component {
static navigationOptions = {
drawerLabel: 'one',
};
render() {
return (
<Button
onPress={() => this.props.navigation.navigate('two')}
title="Go to Two"
/>
);
}
}
components/test/two.js
import React, { Component } from 'react';
import { Button } from 'react-native';
export default class two extends React.Component {
static navigationOptions = {
drawerLabel: 'two',
};
render() {
return (
<Button
onPress={() => this.props.navigation.navigate('three')}
title="Go to 3"
/>
);
}
}
components/test/three.js
import React, { Component } from 'react';
import { Button } from 'react-native';
export default class three extends React.Component {
static navigationOptions = {
drawerLabel: 'three',
};
render() {
return (
<Button
onPress={() => this.props.navigation.goBack()}
title="Go back to 2"
/>
);
}
}
click on "Go to two" => "Go to 3" => "Go back to 2". on screen 3, clicking on the "Go back to 2" is always taking me to one.js.
It is not even working if I combine them in one single file.
