Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React-native: Super expression must either be null or a function, not undefined

Tags:

I have seen similar questions asked but I can't seem to indentify the problem. I am using react native v 0.27 I have changed all my require methods into imports.

Here's the error I receive:

enter image description here

I don't know if its relevant, but the first position of the error points to my LoginComp.js file which contains the following code:

/**
 * 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;
like image 598
noa-dev Avatar asked Jun 07 '16 10:06

noa-dev


2 Answers

Change your import statement like below and try.

import React, { Component } from 'react';

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

Also constructor should be like below

constructor(props){
    super(props);
}
like image 65
Jickson Avatar answered Oct 02 '22 20:10

Jickson


I faced the same issue. Wrongly imported

import React, { Component } from "react-native";

instead of

import React, { Component } from "react";

see this answer https://stackoverflow.com/a/37676646/5367816

like image 25
akhil xavier Avatar answered Oct 02 '22 20:10

akhil xavier