score:3
Your HTML must be in your public folder, in my case terminos.html
- In your
App.js
, add this code:
<Route exact path="/terminos" render={() => {window.location.href="terminos.html"}} />
- If you want to add an anchor, like
<a/>
, add this code:
<a target="_blank" href={process.env.PUBLIC_URL + "terminos.html"} > terminos</a>
score:8
To statically link to a different page, simply use the standard HTML anchor tag:
<a href="normal_redirect.html">Redirect to Html page</a>
When the user clicks on the link, it's a normal page navigation to the href
value of the tag.
To dynamically send the user to another page, use <Route>
component's render
property:
<Route exact path="/normal_redirect" render={() => {window.location.href="normal_redirect.html"}} />
Essentially, use the Route
component's render
property to tell the browser to navigate to a different page: https://reacttraining.com/react-router/web/api/Route
Try this:
class App extends Component {
render() {
return (
<div>
<a href="/Users/yashchoksi/Documents/route/src/normal_redirect.html">Press</a>
</div>);
}
}
Please notice how I've removed the Router
, Route
, Switch
, and Link
components from the code. For a normal link, you don't need any of them.
Source: stackoverflow.com
Related Query
- I want to redirect my reactjs page to regular .html page?
- How to redirect ReactJS page to plain HTML page using button click?
- Redirect to error page ReactJS and react-router
- How To Redirect to Login Page Before Entering Index Route in ReactJS + REDUX
- How to redirect to another page on button click in Reactjs
- Reactjs redirect to dashboard page after successful login with react-router-dom (v6)
- Redirect To Previous Page in ReactJS
- Displaying HTML Body on a page using ReactJS
- How do I reference a React component in a regular HTML page
- Next JS Export to static HTML always redirect to home page "/" on refresh
- How to Redirect to another page in ReactJS when a IF condition is executed?
- ReactJS auth not working, redirect to login page fails
- Want to dynamically handle display of page numbers with respect to Pagination : ReactJS
- I want to redirect to a particular page after getting response from webservice using withRouter in react
- Redirect to the same page that user tried to access before login - Reactjs
- How to detect addEventlistener when html page is already opened via Iframe in Reactjs
- How to handle unAuthorized user and redirect it to 403 page in Reactjs
- How could i use the routing in reactjs to redirect from one page after loading to another url
- How do I redirect after login to another page in ReactJs
- Call API and redirect to next page with same click ReactJS
- reactJs page redirect
- Redirect to login page after session timeout using nodejs, expressjs and reactjs
- how to stop redirect to signUp page once in dashboard- reactjs
- Redirect to a static html page in react.js
- How to redirect to another page and use props in reactjs
- Redirect to another page in reactJS onClick
- Cannot redirect to error Page in ReactJS although I added Link tag
- Redirect to an html page if the route isn't specified
- How do I display this json data with reactjs on my HTML page
- A more elegant way of using Reactjs to redirect a page without setTimout and causing Warning: setState(...): Can only update
More Query from same tag
- change value deep in redux state
- Djanog with React how to reset user password by sending user an email
- JavaScript removeEventlistener callback with argument
- I am trying to map over an array and add comma's in between each instance except for the last
- How to import/add multiple images as per JSON key value in ReactJS?
- How can I expose a property from my `Input` control to any other Component?
- React Error: Target container is not a DOM Element: got when loading a Modal Form
- How to define the order of reducers execution in Redux?
- React HOC can't pass props to enhanced component
- Performing onClick() action and href in <a> tag in React
- What's the best way to set localStorage in React?
- What would this code look like if instead of "async/await" use "then and catch"?
- Import React icons inside stylesheet CSS file
- How to change PublicPath for Create React App in Dev Environment
- How do I redirect into react-router from express?
- getting unauthorized 401 error in MERN application
- How to create relative path in React so images appear
- Trying to create an object that doesn't inherit from ActiveRecord/ApplicationRecord within a Rails controller, but failing
- Redirect to previous path on login - React Router v4
- In React-Router-Dom, my link is changing the url but it is not rendering matched components or passing any props to this.props.child
- React Image upload Dropzone
- React with Kendo-ui Grid - Wrong column header
- duplicate node id's when attempting to re-render vis network canvas on state change
- How to make a reset password system in React + Firebase
- How to get over Cannot read property 'removeEventListener' of null in react
- React Router-DOM - Switch only shows root path
- how to make chartjs columns smaller in width for bar chart?
- How to render multiple notifications with help of notistack in react?
- How to efficiently pass the same "prop" to every stateless presentation component?
- How to send error messages from express to react/redux