2016-12-15 49 views
0

根據https://github.com/ReactTraining/react-router/blob/master/docs/API.md#components-1,我在我的路線中指定了多個組件,並且我收到了警告。它似乎工作正常,但我喜歡聽取警告。反應路由器,多個組件警告:失敗的道具類型:提供給`Route`的道具`組件'無效

Warning: Failed prop type: Invalid prop `component` supplied to `Route`. 

我看到這個警告的其他幾個問題,答案通常是檢查拼寫。我不認爲這是拼寫問題。

<Route path="search" component={Search} /> 
<Route path="search2" component={{main:Search}} /> 

第一個沒有警告,但第二個沒有警告(就像我實際上指定多個組件的路線一樣)。

回答

2

component =通過components財產提供components

多個組件,而不是單一component

// # component; singular 
<Route path="/" component={App}> # component; singular 

    // # components; plural 
    <Route path="groups" components={{main: Groups, sidebar: GroupsSidebar}} /> 
+0

哎呦!錯過了's'。謝謝! *臉紅* – Sigfried

相關問題