close

[Solved] How to use Redirect in the new react-router-dom of Reactjs

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error How to use Redirect in the new react-router-dom of Reactjs in javascript. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How to use Redirect in the new react-router-dom of Reactjs Error Occurs?

Today I get the following error How to use Redirect in the new react-router-dom of Reactjs in javascript.

How To Solve use Redirect in the new react-router-dom of Reactjs Error ?

  1. How To Solve use Redirect in the new react-router-dom of Reactjs Error ?

    To Solve use Redirect in the new react-router-dom of Reactjs Error Simply call it inside any function you like.
    this.props.history.push('/main');

  2. How to use Redirect in the new react-router-dom of Reactjs

    To Solve use Redirect in the new react-router-dom of Reactjs Error Simply call it inside any function you like.
    this.props.history.push('/main');

Solution 1

Simply call it inside any function you like.

this.props.history.push('/main');

Solution 2

The simplest solution to navigate to another component is( Example navigates to mails component by click on icon):

<MailIcon 
  onClick={ () => { this.props.history.push('/mails') } }
/>

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also Read

Leave a Comment