CourseDetail.js
当我单击 TouchableOpacity 时,如何导航到不同的屏幕 ( )。我正在使用它。但StackNavigator
出现错误undefined is not an object evaluating this.props.navigation
。我在下面粘贴我的代码。请帮忙。我知道有一个简单的错误,但无法弄清楚。
HomeScreen.js
import CourseDetail from './CourseDetail';
import { StackNavigator } from 'react-navigation';
const HomeScreen = ({course, navigation}) =>{
const {name,featured_image,id} = course;
const {navigate} = this.props.navigation;
return(
<TouchableOpacity onPress={() => navigate('CourseDetail', {id})}>
<Card>
<CardSection>
<View style={styles.thumbnailContainerStyle}>
{course.term_id == '28' ? (<View></View>) : (
<Text style={styles.userStyle}>{name}
</Text> )}
</View>
</CardSection>
</Card>
</TouchableOpacity>
);
};
const ScheduledApp = StackNavigator({
Home:{
screen: HomeScreen
},
CourseDetail:{
screen: CourseDetail
}
});
export default HomeScreen;