'I want to open a new Tab in React application on button click?

I want to open a table tab in a new window to interact with the component separately. What's the best recommended method to do this functionality in React.js?



Solution 1:[1]

try this pls . <a href="URL_LINK" target="_blank"/>.

such as :

<a href="http://localhost:3001/users" target="_blank"/> 
<a href="http://localhost:3001/personels" target="_blank"/> 

Solution 2:[2]

  1. You can try target="_blank" for opening new tab if you are using <a href="SOME_URL" target="_blank"/>
  2. or you can use onClick event as shown onClick={()=> window.open("someLink", "_blank")} if you just need to put on button .

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Hacı Celal Aygar
Solution 2 Mayank Dwivedi