最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - React Router parent ".active" class not active when child router loaded - Stack Overflow

programmeradmin3浏览0评论

This is how the routes are set up:

var RRoutes = (
<Route handler={App}>

    <Route name="home" path="/" handler={Page} />

    <Route name="portfolio" path="portfolio">
        <DefaultRoute handler={Page} />
        <Route name="portfolio.items" path=":page" handler={test} />
    </Route>

    <Route name="pages" path=":page" handler={Page} />


</Route>
);

When "/portfolio" page is loaded the link gets active. If the child route "portfolio.items" is loaded, the parent active link disappears.. Any suggestions how to get this to work?

This is how the routes are set up:

var RRoutes = (
<Route handler={App}>

    <Route name="home" path="/" handler={Page} />

    <Route name="portfolio" path="portfolio">
        <DefaultRoute handler={Page} />
        <Route name="portfolio.items" path=":page" handler={test} />
    </Route>

    <Route name="pages" path=":page" handler={Page} />


</Route>
);

When "/portfolio" page is loaded the link gets active. If the child route "portfolio.items" is loaded, the parent active link disappears.. Any suggestions how to get this to work?

Share Improve this question edited Aug 9, 2015 at 11:03 Martyboy asked Aug 9, 2015 at 8:54 MartyboyMartyboy 3703 silver badges16 bronze badges 3
  • looking at the handler properties I'm guessing you're using version 0.13.3? – knowbody Commented Aug 9, 2015 at 10:07
  • Yes, "react-router": "^0.13.3" – Martyboy Commented Aug 9, 2015 at 10:19
  • My current work around is adding the "/portfolio" path name to app classes and use "#app.portfolio li.item.portfolio" and set fake active class.. – Martyboy Commented Aug 9, 2015 at 11:08
Add a ment  | 

1 Answer 1

Reset to default 4

Turns out the problem was that I used "/portfolio" instead of "portfolio"

<Link to="portfolio">

Answered by taurose in github. https://github./rackt/react-router/issues/1684

发布评论

评论列表(0)

  1. 暂无评论