Skip to content

Route which only redirects #139

Closed
Closed
@mtscout6

Description

@mtscout6

I have a route that I would like to always do a redirect to a deeper url. My attempt to do so is as follows: (Example is in cjsx, a coffeescript variation of jsx)

Redirect = React.createClass
  displayName: 'Redirect'
  statics:
    willTransitionTo: (transition) ->
      transition.redirect(@props.redirect)
  render: (->)

# TODO: When react-router updates utilize Routes.initialPath
# For details see: https://github.com/rackt/react-router/issues/111
React.renderComponent(
  <Routes location='history'>
    <Route handler={Guide}>
      <Route name='style-guide' path='/style-guide' handler={Redirect} redirect='/style-guide/components' />
      <Route name='components' path='/style-guide/components' handler={StyleGuideComponent} />
      <Route name='icons' path='/style-guide/icons' handler={IconsComponent} />
    </Route>
  </Routes>,
  document.body
)

The problem is that you will ever be able to access the props in willTransitionTo since it's static. Do y'all have any suggestions?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions