1
導航不是按鈕press.This工作是我的登錄page.I想從主屏幕註銷 對onPressLogout()登錄屏幕陣營本地:按鈕onPress不工作
index.js
class Profile extends Component{
static propTypes = {
navigator: PropTypes.shape({
getCurrentRoutes: PropTypes.func,
jumpTo: PropTypes.func,
}),
}
onPressLogout() {
const routeStack = this.props.navigator.getCurrentRoutes();
this.props.navigator.jumpTo(routeStack[0]);
}
render(){
return (
<Container>
<View style={styles.container}>
<Header>
<Button
style={styles.button}
onPress={() => this.onPressLogout()}
>
<Icon name="ios-power" />
</Button>
<Title>Logout</Title>
</Header>
</Container>
);
}
和routeStack
const routeStack = [
{ name: 'Login', component: Login},
]
我已經試過這兩種方法,但還是同樣的錯誤'undefined是不是一個對象:評估_this $ props $ navigator.getCurrentRoutes' – anu
你是否可以只用console.log this.props.navigator並返回結果? – Dan
它在控制檯中顯示一些錯誤。我試圖提醒但沒有結果。 – anu