I wanted to build a Facebook login into my react/react-router/flux application. I have a listener registered on the login event and would like to redirect t
React Router v3
Navigating inside components
You should use withRouter
decorator when it's necessary to redirect inside a component. The decorator uses context instead of you.
import {withRouter} from 'react-router'
fucntion Foo(props) {
props.router.push('/users/16');
}
export default withRouter(Foo);
withRouter(Component, [options])
A HoC (higher-order component) that wraps another component to enhance its props with router props.
withRouterProps = { ...componentProps, router, params, location, routes }
Pass in your component and it will return the wrapped component.
You can explicit specify router as a prop to the wrapper component to override the router object from context.