react-router-reverse
Components and helpers for route reversal in react-router@1.x.x.
<ReverseLink to={routeName} params={params} routes={routes} {...props}/>
Wraps react-router's Link
component to handle route reversal.
routes
can either be passed explicitly as props or implicitly as context.
Since react-router@1.0.0-rc1+ stopped using context, you can still tell your
app to pass down routes using childContextTypes
and getChildContext
.
With props:
;; Component static propTypes = routes: ReactPropTypesarrayisRequired { return <nav> <ReverseLink to="landing" routes=thispropsroutes> Home </ReverseLink> <ReverseLink to="detail" params=id: 5 routes=thispropsroutes> Detail </ReverseLink> </nav> ; }
With context:
;; Component static contextTypes = routes: ReactPropTypesarrayisRequired { return <nav> <ReverseLink to="landing">Home</ReverseLink> <ReverseLink to="detail" params=id: 5>Detail</ReverseLink> </nav> ; }
reverse(routes, name, params)
Reverses a route name given a react-router's routes
.
;; Component static propTypes = routes: ReactPropTypesarrayisRequired { const path = ; thisrouter; } { return <button onClick=thistransitionHome>Go Home</button> ; }
Contributors
- maslianok for writing reverse util.
- joellanciaux for upgrading from react-router@1.0.0-beta3 to react-router@1.0.0-rc3.