Programmatic Navigation

  • go to a link
// if using react-router (v2+)
import { browserHistory } from 'react-router'

// if using newer react-router API inside components (v3+)

// if using react-router-redux
import { push } from 'react-router-redux'
  • go to a link on button click
    onClick={() => browserHistory.push('my/link/')}
Let's go!
  • got to a link and send URL params, query, state whatever along
  onClick={() => browserHistory.push(
			pathname: '/about/',
			query: { name: 'Aamnah' },
			state: { name: 'Aamnah' }
Let's go!

the above is the same as doing this: browserHistory.push("/about/?name=aamnah").

You can access query values (e.g. NAME) in React with this.props.query.NAME or this.props.location.query.NAME and state with this.props.location.state.NAME