Link to google maps doesn't work in react

Viewed 40

i am rendering conditional link by location like this:

  <a
    href={`https://maps.google.com/maps?q=${delivery_branch.latitude},${delivery_branch.longitude}`}
    target={"_blank"}
  >{`${delivery_branch.street}, ${delivery_branch.zip} ${delivery_branch.city}`}</a>

But it doesn't open anything when I try to click on it. When I copy that link a paste it to browser, it works.

1 Answers

Add rel="noopener noreferrer", should work:

<a
    href={`https://maps.google.com/maps?q=${delivery_branch.latitude},${delivery_branch.longitude}`}
    target={"_blank"} rel="noopener noreferrer"
  >{`${delivery_branch.street}, ${delivery_branch.zip} ${delivery_branch.city}`}</a>

Related