-1

Hallo I am new to React and here.

I have questiona about redirect to an URL in React. I am wondering if I can make React page redirect to another URL like www.google.com I did it like .

<a href='http://localhost:8000/api?issuer=ideal_KNABNL2H'>Go to Pay</a> 
<button onclick="window.location.href='http://www.google.com'">

But it doen't work at React. Can it be done in react-router? I have read its doc, still don't know how to make it.

Cheng Ma
  • 1
  • 1

3 Answers3

1

This works well for me

<button onClick={() => window.open( 'http://www.google.com')} >google</button>
Steve Bohmbach
  • 307
  • 1
  • 10
1

You don't need react for this :)

<a href="https://www.google.com/"><button>Visit google</button></a>
Sergej
  • 1,559
  • 11
  • 21
0
<MyLink link="http://www.google.com" title="Google"/>

If it is to redirect to another page, enter http, but if it is to access screen in the project it is used React Router

npm install react-router-dom