close

[Solved] Maintaining href “open in new tab” with an onClick handler in React

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error Maintaining href “open in new tab” with an onClick handler in React 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 Maintaining href “open in new tab” with an onClick handler in React Error Occurs?

Today I get the following error Maintaining href “open in new tab” with an onClick handler in React in javascript.

How To Solve Maintaining href “open in new tab” with an onClick handler in React Error ?

  1. How To Solve Maintaining href “open in new tab” with an onClick handler in React Error ?

    To Solve Maintaining href “open in new tab” with an onClick handler in React Error Above answers are correct. But simply this worked for me
    target={"_blank"}

  2. Maintaining href “open in new tab” with an onClick handler in React

    To Solve Maintaining href “open in new tab” with an onClick handler in React Error Above answers are correct. But simply this worked for me
    target={"_blank"}

Solution 1

You have two options here, you can make it open in a new window/tab with JS:

<td onClick={()=> window.open("someLink", "_blank")}>text</td>

But a better option is to use a regular link but style it as a table cell:

<a style={{display: "table-cell"}} href="someLink" target="_blank">text</a>

Solution 2

Above answers are correct. But simply this worked for me

target={"_blank"}

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