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>
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.
Your HTML must be in your public folder, in my case terminos.html
App.js
, add this code: <Route exact path="/terminos" render={() => {window.location.href="terminos.html"}} />
<a/>
, add this code: <a target="_blank" href={process.env.PUBLIC_URL + "terminos.html"} > terminos</a>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With