" in the "index.js" file; 2. Check "< under "" Route exact path="" component={}/>"Add "exact"."/> " in the "index.js" file; 2. Check "< under "" Route exact path="" component={}/>"Add "exact".">

Home  >  Article  >  Web Front-end  >  What should I do if the react routing page does not refresh?

What should I do if the react routing page does not refresh?

藏色散人
藏色散人Original
2023-01-06 10:58:382905browse

Solution to the react routing page not refreshing: 1. Check in the "index.js" file whether the App component is wrapped in "<BrowserRouter></BrowserRouter>"; 2. In " Add "exact" to "<Route exact path="" component={}/>" under ".

What should I do if the react routing page does not refresh?

The operating environment of this tutorial: Windows 10 system, react-router v5 version, Dell G3 computer.

What should I do if the react routing page does not refresh?

react-router5 The reason why the routing jump page does not refresh

1. In the index.js file Check whether the App component is wrapped in <BrowserRouter></BrowserRouter>.

2. Add exact under <Route exact path="" component={}/> under .

Installation of react-router yarn add react-router-dom

Related expansion:

React Router is a powerful routing based on React library that allows you to quickly add views and data flows to your application while keeping pages and URLs in sync.

The three major frameworks currently popular on the front end all have their own routing implementations:

  • Angular’s ​​ngRouter

  • React’s react-router

  • Vue's vue-router

Starting from version 4 of React Router, routes are no longer managed in one package. :

  • react-router is the core part of the router code

  • react-router-dom is used for browsers;

  • react-router-native is used for native applications;

Currently we use the latest React Router version which is the v5 version:

In fact, there is not much difference between the version of v4 and the version of v5;

Install react-router:

Installing react-router-dom will automatically help us install the dependencies of react-router;

yarn add react-router-dom

Recommended learning: "react video tutorial"

The above is the detailed content of What should I do if the react routing page does not refresh?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn