2017-12-22 28 views
3

내 경로는 다음과 같이 설정되어 "중복"하는 유사한 경로 (고정 및 동적 경로 PARAM)와 라우터 V4 구성 요소를 반응한다. /chat/newNewChat으로 전화하면 독점적으로 전화 할 수 있습니까?

답변

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을 활용하여 경로를 순서 것