我发现各种类似的问题都有不同的问题和解决方案。我想导航到Auth但有错误undefined不是一个对象(评估'this.props.navigation.navigate')......... .................................................. ...................
ReviewScreen.js
import React,{Component} from 'react';
import {View,Text,Platform} from 'react-native';
import {Button} from'react-native-elements'
class ReviewScreen extends Component{
static navigationOptions = ({ navigation }) => {
return {
title: 'Review Jobs',
headerRight: (
<Button title='Settings'
onPress={() => navigation.navigate('settings')}
backgroundColor="rgba(0,0,0,0)"
color="rgba(0,122,255,1)"
/>
),
style:{
marginTop:Platform.OS==='android'?24:0
}
};
}
render(){
return(
<View>
<Text>ReviewScreen</Text>
<Text>ReviewScreen</Text>
<Text>ReviewScreen</Text>
<Text>ReviewScreen</Text>
<Text>ReviewScreen</Text>
<Text>ReviewScreen</Text>
<Text>ReviewScreen</Text>
</View>
);
}
}
export default ReviewScreen;
WelcomeScreen.js
import React, {Component} from 'react';
import {View, Text} from 'react-native';
import Slides from '../components/Slides'
const SLIDE_DATA = [
{text: 'Welcome to JobApp', color: '#03A9F4'},
{text: 'Use this to get a job', color: '#009688'},
{text: 'Set your location,then swipe away', color: '#03A9F4'}
];
class WelcomeScreen extends Component {
onSlidesComplete() {
this.props.navigation.navigate('auth')
}
render() {
return (
<Slides data={SLIDE_DATA} onComplete={this.onSlidesComplete}/>
);
}
}
export default WelcomeScreen;
答案 0 :(得分:0)
方法onSlidesComplete
不是代码中this
的一部分。根据ES6,你必须这样:
class WelcomeScreen extends Component {
onSlidesComplete = () => {
this.props.navigation.navigate('auth')
}
render() {
return (
<Slides data={SLIDE_DATA} onComplete={this.onSlidesComplete}/>
);
}
}