2015-12-17 13 views
8

私はこのようなルート設定を持っています。react-router - コンポーネントのネストなしでネストされたルートを作成します

<Route path="group/:groupId" component={NonPropertyView}> 
<Route path="group/:groupId/line/:lineId" component={NonPropertyView} /> 
<Route path="group/:groupId/line/:lineId/property/:propertyId" component={PropertyView} /> 

これを行うことはできますか?私が探しています何

<Route path="group/:groupId" component={NonPropertyView}> 
    <Route path="line/:lineId" component={NonPropertyView}> 
    <Route path="property/:propertyId" component={PropertyView} /> 
    </Route> 
</Route> 

はちょうど親ルートComponentをレンダリングすることなく、葉のルートのためのComponentをレンダリングするためのオプションです。これは可能ですか?

答えて

14

はい - <IndexRoute>を使用してください。たとえば、上記のように書く:

<Route path="group/:groupId"> 
    <IndexRoute component={NonPropertyView} /> 
    <Route path="line/:lineId"> 
    <IndexRoute component={NonPropertyView} /> 
    <Route path="property/:propertyId" component={PropertyView} /> 
    </Route> 
</Route> 
関連する問題