我正在为 iOS 构建一个 React-native 应用程序(我对这个框架相当陌生)。
我有一个按钮,一旦您单击它,它就会带您进入登录视图,一旦用户单击该按钮,它应该将用户导航到 LoginPage 组件。但是目前,当我这样做时,我会收到您在图像中看到的错误。
'use strict'
import React, { Component } from 'react';
import {
Platform,
StyleSheet,
Text,
View,
Image,
Button,
ActivityIndicator,
TouchableOpacity,
} from 'react-native';
import LoginPage from './login';
type Props = {};
export default class App extends Component<Props> {
myPress = () =>{
//This is where the error occurs
this.props.navigator.push({
title: 'log in to YourHope.io',
component: login,
passProps: null,
});
}
render() {
let pic = {
uri: 'https://example.com'
};
let logo = {
uri: 'https://example.com'
}
const companyName = 'Example LLC';
const message = 'cool welcome';
return (
<View style={{ flex: 1, backgroundColor: '#eee', }} >
...
<TouchableOpacity
style={styles.loginScreenButton}
onPress={this.myPress}
underlayColor='#fff'>
<Text style={styles.loginText}>login</Text>
</TouchableOpacity>
</View>
</View>
);
}
}
这是登录视图:
'use strict';
import React, { Component } from 'react'
import {
StyleSheet,
Image,
View,
TouchableHighlight,
FlatList,
Text,
} from 'react-native';
export default class LoginPage extends Component<{}> {
render() {
return (
<Text></Text>
);
}
}