i have used react router doms' Link:

<Link target="_blank" to={"www.mylink.com"} >mylink </Link>

but this would open new tab to http://localhost:3000/www.mylink.com also, using a href:

<a href={'www.mylink.com'} target="_blank" > mylink </a>

does the same. opens new tab to http://localhost:3000/www.mylink.com how do i open in new tab only the link?

try this

<Link target="_blank" to={"//www.mylink.com"} >mylink </Link>

or this

<a href={'//www.mylink.com'} target="_blank" > mylink </a>

for more reference:
Absolute vs relative URLs

20 users liked answer #0dislike answer #020
am05mhz profile pic

I tried to use Link but I had the same problem. Now I'm using this onClick={() => { window.open('LINK','_blank')}}

1 users liked answer #1dislike answer #11
Pelin Diskan profile pic
Pelin Diskan

When I used Link like

<Link to={`//${isHrefVlaue}`}></Link>

this was opening without localhost, but it was missing the colon in https and not working as expected.

But then it worked after I replaced Link with an anchor like

<a href={isHrefVlaue}></a>
0 users liked answer #2dislike answer #20
Nikhil Chakravarthy profile pic
Nikhil Chakravarthy

Copyright © 2022 QueryThreads

All content on Query Threads is licensed under the Creative Commons Attribution-ShareAlike 3.0 license (CC BY-SA 3.0).