3 ways of redirections in react-router

3 Types of Navigation Requests in React JS Web Applications

1) Links — Replacements of <a> tags in reactjs web apps

import { Link } from 'react-router-dom'
<Link to="/">...text, button or other elements....</Link>

2) Redirections as Component in “render” methods

if (!authorized) {
return <Redirect to="/login" />
}

3) Programmatical redirect from javascript

import { createBrowserHistory } from 'history'
const history = createBrowserHistory()
<Provider store={store}>
<BrowserRouter history={history}>
<Route path="/:filter?" component={App} />
</BrowserRouter>
</Provider>
const { history } = this.props
history.push('/dashboard')

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store