2016-06-07 25 views
7

Sorulan benzer soruları gördüm ama sorunu özdeşleştiremiyorum. Tepki yerel kullanıyorum 0.27 Tüm gereksinim yöntemlerini içe aktarma işlemlerini değiştirdim. onun ilgiliyseReact-native: Süper ifadesi null veya bir işlev olmalıdır, undefined değil

enter image description here

Bilmiyorum, ancak aşağıdaki kodu içeren benim LoginComp.js dosyasına hata noktalarının birinci pozisyon: Burada

aldığım hata var

/** 
* 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; 

cevap

27

İçe aktarma ifadenizi aşağıdakine benzer şekilde değiştirin ve deneyin.

Ben import Module from "./path/to/Module.js" gibi varsayılan bir modülü ithal ediyordu:

constructor(props){ 
    super(props); 
} 
+0

Teşekkürler - sorunumu çözdü. Ama neden böyle olmak zorunda? –

+5

Yerel olarak tepki veren en son sürümde, 'React' ve 'Component', 'react-native' konumundan 'react' modülüne taşınır. Yani yukarıdaki yolu kullanarak onu almak zorunda kalacaksınız. – Jickson

+0

ve bağlam hakkında yapıcı ne iletir? –

1

personnaly altında, başka bir şekilde bu sorunu çözmüş gibi

import React, { Component } from 'react'; 

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

Ayrıca yapıcı olmalıdır. Bu kimse yardımcı olacaktır>export default class Module {/*...*/}

Umut -
export class Module {/*...*/}:
Ama Module.js dosyada, varsayılan anahtar kelime ommited. =)

İlgili konular