Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contextual Links not working correctly #117

Open
UberMouse opened this issue Jan 30, 2015 · 1 comment
Open

Contextual Links not working correctly #117

UberMouse opened this issue Jan 30, 2015 · 1 comment

Comments

@UberMouse
Copy link

I have the following two routers

Parent

   <Locations path={@props.path}>
      <Location path="/" handler={HomePage} />
      <Location path="/:steamId(/*)" handler={GamesRouter} />
      <NotFound handler={NotFoundHandler} />
    </Locations>

Nested (Side note, without setting the path manually like I am none of the routes match for the nested router)

    path = "/" + if(@props._?) then @props._[0] else ""
    <Locations path={path} contexual>
      <Location path="/stats" handler={StatsPage} />
      <Location path="/games" handler={ViewGamesPage} />
      <NotFound handler={NotFoundHandler} />
    </Locations>

And on the StatsPage and the ViewGamesPage I wrap both of the their renders in a GamesLayout component (Is there a better way to do layouts for individual routers?) and in the GamesLayout I have a nav bar with some Links for the '/games' and '/stats' relative urls but they are linking to root/games instead of root/:steamId/games so they don't work. As a work around I am just including the steamId in the url manually. The GamesLayout component mixes in the NavigatableMixin to get access to the current path, which is correctly scoped to the contextual routers path.

I am generating the Links like this

    routes = [{path: '/stats', name: 'Stats'}, {path: '/games', name: 'Games List'}].map (route, index)=>
      classes = React.addons.classSet('active': @getPath() == route.path)
      <li className={classes} key={index}><Link href={"/#{@state.steamId}/#{route.path}"}>{route.name}</Link></li>

Does anyone know why the contextual linking is failing? Am I missing something in my routes?

The code is at https://github.com/UberMouse/SteamLibraryLength with the React code located at webpack/assets/javascripts (Parent router is in app.cjsx and child router is in games/router.cjsx with the Links being in games/layout.cjsx

@jsg2021
Copy link
Contributor

jsg2021 commented May 29, 2015

contextual router is mounted under the /:streamId(/*) route. The contextual part matches against the remainder bit: (/*)

Have you tried not starting your link with /#{@state.steamId}/ instead just do #{route.path}?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants