react open new tab with url Example Tutorial

Today, We want to share with you react open new tab with url.In this post we will show you How to Open URL in New Tab using ReactJS, hear for Programmatic Navigation in React using react-router we will give you demo and example for implement.In this post, we will learn about Open a URL in a new tab (and not a new window) with an example.

react open new tab with url

There are the Following The simple About How to Open URL in New Tab ReactJS Full Information With Example and source code.


As I will cover this Post with live Working example to develop ReactJS url parameter to open in new tab, so the open link in new window, not tab is used for this example is following below.

Read Also:  open new tab in reactjs Example Tutorial

React-Router External link

one-liner for using React Router to redirect to an external link

<Route path='/conatct-us' component={() => { 
     window.location.href = 'https://www.pakainfo.com/98989'; 
     return null;
}}/>

go to external link use an anchor tag.

<a target="_blank" href="https://www.pakainfo.com/terms-and-conditions/" rel="noopener noreferrer">Terms And Conditions</a>

react open link in new tab programmatically

Custom Component.

<Route
  path="/privacy-policy"
  component={ Redirect }
  loc="https://www.pakainfo.com/privacy-policy/"
  />

component incase-anyone

import React, { Component } from "react";

export class Redirect extends Component {
  constructor( props ){
    super();
    this.state = { ...props };
  }
  componentWillMount(){
    window.location = this.state.route.loc;
  }
  render(){
    return (<section>Redirecting...</section>);
  }
}

export default Redirect;

Web Programming Tutorials Example with Demo

Read :

Read Also:  Create Animated Scroll To Top Button using jQuery

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about open link in new tab react.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.