몇 가지 github 문제와 유사한 게시물을 살펴 봤지만이를 파악할 수 없습니다. 여기에 내 경로가 있습니다.
<Router history={browserHistory}>
<Route path='/' component={Main}>
<IndexRoute component={Landing} />
<Route path='login' component={LoginContainer} />
<Route path='user' component={UserContainer} onEnter={checkAuth} >
<Route path='home' component={HomeContainer} />
<Route path='settings' component={SettingsContainer} />
<Route path='doc_attributes' component={AttributesContainer} />
<Route path='groups' component={GroupsContainer} />
<Route path='rules' component={RulesContainer} />
</Route>
<Route path='/dropbox/auth_finish' onEnter={doDropbox} />
<Route path='/box/auth_finish' onEnter={doBox} />
<Route path='/googledrive/auth_finish' onEnter={doGDrive} />
<Route path='/onedrive/auth_finish' onEnter={doOneDrive} />
</Route>
</Router>
관심있는 링크는 다음과 같습니다.
<li><Link to='/user/home' activeClassName="activeLink"><i className="fa fa-home fa-3x fa-fw" aria-hidden="true"></i></Link></li>
<li><Link to='/user/settings' activeClassName="activeLink"><i className="fa fa-wrench fa-3x fa-fw" aria-hidden="true"></i></Link></li>
<li><Link to='/user/groups' activeClassName="activeLink"><i className="fa fa-users fa-3x fa-fw" aria-hidden="true"></i></Link></li>
<li><Link to='/user/rules' activeClassName="activeLink"><i className="fa fa-tasks fa-3x fa-fw" aria-hidden="true"></i></Link></li>
링크는 정상적으로로드되지만 활성 클래스 CSS를 얻지 못합니다. 로드시 첫 번째 경로 만 가져옵니다. 아무도 아이디어가 있습니까?
그래서이 질문을받은 지 오래되었지만 답을 알아 내서 공유해야합니다.
구성 요소를 렌더링하고 탐색을위한 상태 업데이트를받는 컨테이너 {pure: false}
에서 connect 함수 를 입력해야했습니다 . 본질적으로 구성 요소가 "순수"(업데이트는 props에서만 제공됨)가 아닌 경우 반응 컨텍스트에 의존하여 다시 렌더링한다는 사실과 관련이 있습니다. 다음은 코드 블록입니다.
const NavContainer = ReactRedux.connect( MapStateToProps, MapDispatchToProps, null, {pure: false} )(Nav)
문제에 대한 문서 : https://github.com/reactjs/react-redux/blob/master/docs/troubleshooting.md
내가 해결하는 데 도움이 된 문제 : https://github.com/ReactTraining/react-router/issues/3286
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다