2017-10-13 101 views
-1

我在「預期的組件類,得到[對象對象]」上遇到此問題。我已經查找了Stack中的所有相關問題,我通過大寫我的對象來跟蹤其中的大部分問題,但發生了相同的錯誤。一些偉大的指針將不勝感激。預期組件類,得到[對象對象] - 反應本機

這是我App.js文件

import React from 'react'; 
import { StyleSheet, AppRegistry, Text, View } from 'react-native'; 
import Login from "./Login"; 

export default class App extends React.Component { 
    render() { 
    return (
    <Login /> 
    ); 
    } 
} 

和我Login.js文件

import React from 'react'; 
import{ 
StyleSheet, 
View, 
Text, 
Image, 
touchableOpacity, 
TextInput, 
KeyboardAvoidingView 
} from 'react-native'; 

export default class Login extends React.Component{ 
render(){ 
    return(
    <KeyboardAvoidingView 
    behavior="padding" 
    style={styles.container}> 
     <View style={styles.logoContainer}> 
     </View> 
     <View style={styles.formContainer}> 
     <TextInput 
      underlineColor="transparent" 
      placeholder="Email" 
      returnKeyType="next" 
      keyboardType="email-address" 
      onSubmitEditing={()=> this.passwordInput.focus()} 
      style={styles.input}/> 
     <TextInput 
      underlineColor="transparent" 
      placeholder="Password" 
      secureTextEntry 
      returnKeyType="go" 
      ref={(input) => this.passwordInput = input} 
      style={styles.input}/> 
      <touchableOpacity 
      style={styles.buttonContainer}> 
      <Text style={styles.textButton}>Login</Text> 
      </touchableOpacity> 
     </View> 
    </KeyboardAvoidingView> 
    ); 
    } 
    } 

它返回預期的組件類的錯誤,拿到的翻譯:

提前致謝。要麼我太盲目,看不到我的錯誤,要麼我完全錯了。

+1

'touchableOpacity'是小寫的'Login' ... – Li357

+0

@AndrewLi是解決該問題謝謝! – Yikern

回答

0

發現錯誤,我只需要大寫我的組件。 touchableOpacity - >TouchableOpacity 感謝李國