upog
upog

Reputation: 5526

React Link to - provide absolute path

I have below code

<Link className={classes.btnText}  key= {props.id} 
                to= {"https://s3.amazonaws.com/pdf/download.pdf" } target="_blank" download>Brochure <span> &darr; </span> </Link>

The issue is i'm not able to give the absolute path. It is getting updated as

localhost:3000/https://s3.amazonaws.com/pdf/download.pdf

Can i know how to give complete url

Upvotes: 3

Views: 2847

Answers (3)

ummahusla
ummahusla

Reputation: 2063

You can use <a> tag instead

<a href="https://s3.amazonaws.com/pdf/download.pdf" target="_blank" className={classes.btnText}>

Upvotes: 5

Wahab Shah
Wahab Shah

Reputation: 2266

Yeah because Link builds all the routes from your home/root path which is localhost:3000 in local dev environment. So that's why its appending to that.

use hyperlink tag <a> instead

Upvotes: 1

AdamKniec
AdamKniec

Reputation: 1727

That's how the {Link} works :)

Maybe use <a> tag instead ?

Upvotes: 1

Related Questions