2016-08-13 7 views
0
class PathComponents extends React.Component{ 
... 
render(){ 
var articlesPath = this.state.titles.map(function(val){ 
    return(
    <Route path={val} component={DataVisualizationBox}/> 
) 
}) 
return(
    <Router history={browserHistory}> 
    <Route path="/" component={Main}> 
     <IndexRoute component={DataOverviewBox}/> 
     <Route path="/" component={DataOverviewBox}/> 
     <Route path="dataVis" component={DataVisualizationBox}/> 
     <Route path="compare" component={DataComparison}/> 
     <Route path="overallStats" component={DataBox}/> 
     <Route path="dataCrawling" component={DataCrawlerBox}/> 
     {articlesPath} 
    </Route> 
    </Router> 
) 
} 
} 

ReactDOM.render(<PathComponents/>, mainPage); 

私は上記のコードを持っています(いくつかの部分は無関係であるため削除されています)。自分のデータベースにある記事に基づいて、別の記事タイトルへのルートを作成したいと考えています。しかし、私はエラーメッセージ:React jでルートオブジェクトを作成する

警告:[反応ルータ]場所 "いくつかのタイトル"はどのルートにも一致しませんでした。

誰でも知っていますか?

答えて

0

あなたは間違っています。あなたは1000のルート

<Router history={browserHistory}> 
    <Route path="/" component={Main}> 
     <IndexRoute component={DataOverviewBox}/> 
     <Route path="/" component={DataOverviewBox}/> 
     <Route path="dataVis" component={DataVisualizationBox}/> 
     <Route path="compare" component={DataComparison}/> 
     <Route path="overallStats" component={DataBox}/> 
     <Route path="dataCrawling" component={DataCrawlerBox}/> 
     <Route path="/:article_title" component={ArticleViewer}/> 
     {'add this route, also note this is absolute path'} 
    </Route> 
    </Router> 

で終わるしたくない1000年の記事があるとしArticleViewerコンポーネント内には、

var title = this.props.params.article_title; 
//from this title extract your article somehow 
ような何かを行うことができます
関連する問題