2017-04-15 6 views
1

私はReact-Nativeプロジェクトに取り組んでおり、反応ナビゲーションを実装しようとしている間に問題がありました。 私はチュートリアルに続き、プロジェクトを実行しようとすると、私が言うエラーが出る:要素タイプが無効です:文字列/クラス/関数がありますオブジェクト:

Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. You likely forgot to export your component from the file it’s defined in. 

を、私はこのサイトを含め、ウェブを検索するが、任意の解決策を見つけることができませんでした。 これは私のコードです: index.js:

import React, { Component } from 'react'; 
import { Stack } from './config/Router'; 

class Application extends Component{ 
    render(){ 
    <View> 
     return <Stack />; 
    </View> 
    } 
} 

export default Application; 

これはルータです:

import React from 'react'; 
import { StackNavigator } from 'react-navigation'; 

import Login from '../components/Login'; 
import Home from '../components/Home'; 

export const Stack = StackNavigator({ 
    Login:{ 
    screen: Login 
    }, 
    Home:{ 
    screen: Home, 
    navigationOptions: { 
     title: 'Home' 
    } 
    } 
}); 

、これはindex.ios.jsです:

import { AppRegistry } from 'react-native'; 
import Application from './index' 

AppRegistry.registerComponent('Application',() => Application); 

私はどのように修正することができますエラー?前もって感謝します!

class Application extends Component{ 
    render(){ 
    <View> 
     return <Stack />; 
    </View> 
    } 
} 

class Application extends Component{ 
    render(){ 
    return(
     <View> 
     <Stack /> 
     </View> 
    ); 
    } 
} 

また、あなたは、これはほとんど常にある

You likely forgot to export your component from the file it’s defined in.

index.jsにViewコンポーネントをインポートする必要がありますする必要がありますように見えます

答えて

1

なぜなら、無効な要素エラーが発生するからですあなたの輸入品を再確認してください。

+0

ありがとうございますが、私はまだ同じエラーがあります。 –

+0

@ JohnDoahおそらくindex.jsの 'View'コンポーネントをインポートする必要があります – Emobe

関連する問題