react open link in new tab code example

Example 1: open link in new tab

<a href="https://www.google.com/" rel="noopener noreferrer" target="_blank">google.com</a>

dont use just target="_blank" without  rel="noopener noreferrer" 
It Makes Your Site Vulnerable to Phishing Attacks

Example 2: open a new tab when clicking on a link react

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

Example 3: how to open a new tab in react

//More Secure Solution. For JS only.

const openInNewTab = (url) => {
  const newWindow = window.open(url, '_blank', 'noopener,noreferrer')
  if (newWindow) newWindow.opener = null
}

//Then add to your onClick
onClick={() => openInNewTab('https://stackoverflow.com')}

Example 4: open in a new tab react

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