With react-router
I can use the Link
element to create links which are natively handled by react router.
I see internally it calls t
React-Router v2
For the most recent release (v2.0.0-rc5
), the recommended navigation method is by directly pushing onto the history singleton. You can see that in action in the Navigating outside of Components doc.
Relevant excerpt:
import { browserHistory } from 'react-router';
browserHistory.push('/some/path');
If using the newer react-router API, you need to make use of the history
from this.props
when inside of components so:
this.props.history.push('/some/path');
It also offers pushState
but that is deprecated per logged warnings.
If using react-router-redux
, it offers a push
function you can dispatch like so:
import { push } from 'react-router-redux';
this.props.dispatch(push('/some/path'));
However this may be only used to change the URL, not to actually navigate to the page.