2017-12-22 25 views
3

マイルートがこのように設定されている「オーバーラップ」される同様の経路(固定及び動的パスPARAM)とルータV4成分を反応させます。 /chat/newにアクセスしたときに、NewChatに専属電話する方法はありますか?

答えて

5

あなたはSwitch

<Switch> 
    <Route path="/chat/new" component={NewChat} /> 
    <Route path="/chat/:id" component={Chat} /> 
</Switch> 
0
<Route 
    path="/chat/:id/" 
    render={ props => { 

     if(props.location.pathname != '/chat/new') return <Chat {...props} /> 
     else return null; 

    } } 
/> 
<Route path="/chat/new" component={NewChat} /> 

Routeはあなたが、これは、同様

ソリューションである可能性があり設定に依存マッチした最初のレンダリング以来、 Switchを利用すると、あなたのルートを並べ替えます