0

나는 그렇게 여러 노선에서 라우터에게 반작용 4

다음 구성을 사용하고 있습니까? 이 권리가 있습니까, 아니면 공동체가이 용도로 사용할 다른 것을 권유합니까?

import {Route, Switch} from 'react-router'; 
import {ConnectedRouter} from 'react-router-redux'; 

<ConnectedRouter history={app.history}> 
    <div> 
     <Route exact path="/page1" component={Page1} /> 
     <Route exact path="/page2" component={Page2} /> 
     <Route exact path="/page3" component={Page3} /> 
     <Route exact path="/:animal?" component={Animal} /> 
    </div> 
</ConnectedRouter> 

답변

0

정확한 경로 대신 미래에 어린이를 추가해야 할 수도 있으므로 색인 경로를 사용하고 싶을 수도 있습니다. 따라서 다른 경로에서 앱을 분리하여 루트 구성에서 자녀로 렌더링 할 항목을 결정하도록하는 것이 좋습니다 (나중에 사용하려는 경우)

작은 내부에 작은 앱을 만들고 싶습니다. 애플 리케이션, 큰 것들!

<Router history={browserHistory}> 
    <Route path="/" component={App}> 
     <IndexRoute component={some_component}></IndexRoute> 
    </Route> 
    <Route path="/xyz" component={App}> 
     <IndexRoute component={xyz}></IndexRoute> 
    </Route> 
    <Route path="/abc" component={App}> 
     <IndexRoute component= {abc}></IndexRoute> 
    </Route> 
    <Route path="/*" component={NotFound} /> 
    </Router>, document.getElementById('app') 
); 

희망이 도움이됩니다.

+0

OP가 자신의 코드를 작성한 방식에서 v4를 사용한다고 가정하면이 문제는 도움이되지 않습니다. –

+0

@ShubhamKhatri 예 v4를 사용하고 질문 제목에서 언급했습니다. – learner