score:16

Accepted answer

you can use a tag for external urls,

<a href='https://domain.extension/external-without-params'>external</a>

but also you can provide component like this:

<route path='/external' component={() => { window.location = 'https://domain.extension/external-without-params'; return null;} }/>

score:-1

can easily use a button just do this:

<button onclick={(e) => (window.location = 'https://www.google.com')}>click me</button>

score:0

have on mind that you cannot perform that with <link /> or <navlink /> since they're mainly for routing throughout single page application.

you should use anchor tag instead. example: <a href="https://www.google.com">google</a>.

score:1

in case you're using typescript you probably will get the following error with the accepted answer:

type 'string' is not assignable to type 'location'

to fix that you just need to use window.location.href

<route path="/external" component={() => {window.location.href = config.upgrade_url return null }} />

score:3

you can use window.open() to redirect to any website.

for example:

window.open('https://www.google.com');

implement redirection in your code:

render () {
  if(this.islogin) {
    return(/* your components*/);
  } else {
    window.open('https://www.google.com');
    return (<div></div>); //render function should return something
  }
}

you can also specifies the target attribute or the name of the window, for more details, see w3school tutorial about this function.


Related Query

More Query from same tag