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:
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;
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);
}
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With