-
-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Closed
Description
In my project i need to call transitionTo("/some/path")
in a function to go to a different location.
That function is available in the router context, why not pass it down as a prop to the matched component?
My solution was to wrap match with the router
from the context
import React from 'react';
import {Match, propTypes} from 'react-router';
const CustomMatch = (props, context) => {
return (
<Match {...props} render={(matchProps) => {
const newProps = {...matchProps, router: context.router, ...props};
if (props.component)
return React.createElement(props.component, newProps);
else
return props.render(newProps);
}}/>
);
};
CustomMatch.contextTypes = {
router: propTypes.routerContext
};
export default CustomMatch;
gchudnov, zombieJ, sunabozu, ayush000, erikrahm and 1 more
Metadata
Metadata
Assignees
Labels
No labels