Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I want to redirect my reactjs page to regular .html page?

I want redirect my reactjs page to regular html page on pressing click me like link button.

Here's my code:

App.js

import React, { Component } from 'react';
import { BrowserRouter as Router, Switch, Route, Link } from 'react-router-dom';
import './App.css';
// import DoctorImg from './doctor.jpg';

class App extends Component {
  render() {
    return (
      <Router>
      <div>
        <Link to="/Users/yashchoksi/Documents/route/src/normal_redirect.html">Press</Link>
      <Switch>
        <Route exact path="/Users/yashchoksi/Documents/route/src/normal_redirect.html"/>
      </Switch>
    </div>
    </Router>
    );
  }
}

export default App;

Other file is

normal_redirect.html

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Check this.</title>
  </head>
  <body>
    <p>This is redirected page.</p>
  </body>
</html>
like image 888
Yash Choksi Avatar asked Feb 21 '18 04:02

Yash Choksi


People also ask

How do I redirect a reacted page?

The Redirect component was usually used in previous versions of the react-router-dom package to quickly do redirects by simply importing the component from react-router-dom and then making use of the component by providing the to prop, passing the page you desire to redirect to.


1 Answers

Your HTML must be in your public folder, in my case terminos.html

  1. In your App.js, add this code:
    <Route exact path="/terminos" render={() => {window.location.href="terminos.html"}} />
  1. If you want to add an anchor, like <a/>, add this code:
     <a target="_blank" href={process.env.PUBLIC_URL + "terminos.html"} > terminos</a>
like image 154
Israel Santiago Pancca M. Avatar answered Sep 19 '22 13:09

Israel Santiago Pancca M.