user17049514
user17049514

Reputation:

How to open a link in a new tab using react?

I have that function :

const test =  () => {
    var url = "https://www.google.fr";
    window.location.href = url;
    }

But I would like to open Google in a new tab. How can I do to do that ?

Thank you very much !

Upvotes: 0

Views: 3198

Answers (1)

Krushnasinh Jadeja
Krushnasinh Jadeja

Reputation: 624

Try this one:

window.open(URL, '_blank');

Upvotes: 4

Related Questions