React-native:超级表达式必须为 null 或函数,而不是未定义

新手上路,请多包涵

我看到过类似的问题,但我似乎无法确定问题所在。我正在使用 react native v 0.27 我已将所有 require 方法更改为导入。

这是我收到的错误:

在此处输入图像描述

我不知道它是否相关,但错误的第一个位置指向我的 LoginComp.js 文件,其中包含以下代码:

 /**
 * Sample React Native App
 * https://github.com/facebook/react-native
 */
'use strict';
import React, {
  AppRegistry,
  Component,
  StyleSheet,
  Text,
  View,
  Image,
  TextInput,
  Button,
  TouchableHighlight
} from 'react-native';

class LoginComp extends Component {
  constructor(){
    super(props);
  }
  render() {
    return (
      <View style={{flex: 1}}>
        <View style={this.props.styles.loginLogoContainer}>
          <Image style={this.props.styles.view1logo} source={require('../imgs/Logo.png')} />
        </View>
        <View style={this.props.styles.loginContainer}>
          <Text>Użytkownik:</Text>
          <TextInput
            style={this.props.styles.defaultInput}
            placeholder="Użytkownik"
            stretch={true}
            autoComplete={false}
            autoCorrect={false}
          />
          <Text>Hasło:</Text>
          <TextInput
            style={this.props.styles.defaultInput}
            placeholder="Hasło"
            stretch={true}
            autoComplete={false}
            autoCorrect={false}
            secureTextEntry={true}
          />
        <TouchableHighlight onPress={this.props.LoginPress}>
            <Text style={this.props.styles.loginButton}>Login</Text>
          </TouchableHighlight>
        </View>
        <View style={this.props.styles.registrationWrapper}>
          <Text>- lub -</Text>
          <TouchableHighlight onPress={this.props.t_Registration}>
            <Text style={this.props.styles.registration}>Załóż nowe konto</Text>
          </TouchableHighlight>
        </View>
      </View>
    );
  }
}

module.exports = LoginComp;

原文由 noa-dev 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 387
1 个回答

如下更改您的导入语句并尝试。

 import React, { Component } from 'react';

import {
  AppRegistry,
  StyleSheet,
  Text,
  View,
  Image,
  TextInput,
  Button,
  TouchableHighlight,
} from 'react-native';

构造函数也应该如下所示

constructor(props){
    super(props);
}

原文由 Jickson 发布,翻译遵循 CC BY-SA 3.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题