2016-06-22 9 views
2

私はブラウザ上で私のアプリを実行すると、私は私のコンソールに乗る:警告:失敗しましたpropType:無効な小道具「コンポーネントは、」「ルート」に供給

「警告:失敗しましたpropType:無効な小道具 『コンポーネント』の供給'ルート'」

への私のroutesファイル:

import { Route, IndexRoute } from 'react-router'; 
import React from 'react'; 
import App from './container/App'; 
import PContainer from './container/PContainer/PContainer'; 
import PView from './container/PView/PView'; 

const routes = (
<Route path="/" component={App} > 
    <IndexRoute component={PContainer} /> 
    <Route path="/Posts View" component={PView} /> 
</Route> 
); 

export default routes; 

マイPVieワットのファイル:私はこのエラーを取得していますなぜ

import React, { Component, PropTypes } from 'react'; 
import { connect } from 'react-redux'; 

class PView extends Component { 

render() { 
    return (
    <div> 
    <h1>List of Posts</h1> 
    </div> 
); 
} 
} 

export default connect()(PView); 

誰も教えてもらえますか?

+0

は、 ' Vikramaditya

+0

はい可能です。 –

+1

[警告:失敗したpropType:\ Route \]に無効なprop \ 'component \']が重複している可能性があります(http://stackoverflow.com/questions/33950433/warning-failed-proptype-in​​valid-prop-component- – James111

答えて

1

App、PContainer、およびPViewがすべて有効なReactコンポーネントであることを確認してください。モジュールのインポートとエクスポートをチェックします。エクスポートは "default"でなければなりません。そうでない場合は、名前付きインポートを使用する必要があります:import {somecomp} from './somecomp'。コンポーネントへのルートを確認してください。

あなたのルートはちょっと変わっています:'./container/PContainer/PContainer''./container/PView/PView'です。あなたはPContainerPVIEWのフォルダを持っていない場合

多分それは、'./container/PContainer''./container/PView'でなければなりません。

関連する問題