课程: React: Creating and Hosting a Full-Stack Site
免费学习该课程!
今天就开通帐号,24,700 门业界名师课程任您挑!
Loading data For React Router routes - React.js教程
课程: React: Creating and Hosting a Full-Stack Site
Loading data For React Router routes
- [Instructor] All right, so now that we've installed Axios, let's see how we can actually load data for the different routes in our React application. So, what I'm going to do is I'm going to open up the frontend application again. We haven't been in here in a little while, but we're going to go into App.jsx and take a look at the routes array that we created inside of there. Now, remember that what this Routes Array did is it defined what component, right, what page component should be displayed for each path. So, we had this surrounding Layout component that basically was in charge of displaying the nav bar, and then we had the HomePage, AboutPage, ArticlesListPage, and ArticlePage. So, what we're going to need to do here in order to load data for one of these pages is we actually just need to specify another property in one of these objects, and that is a property called loader. Now, the way that this works is we simply need to specify a function for this loader property that will…
内容
-
-
-
-
-
-
(已锁定)
The Axios library1 分钟 17 秒
-
(已锁定)
Loading data For React Router routes4 分钟 40 秒
-
(已锁定)
Using the useLoaderData hook6 分钟 12 秒
-
(已锁定)
Using route parameters in loaders3 分钟 58 秒
-
(已锁定)
Displaying comments3 分钟 21 秒
-
(已锁定)
Creating an upvote button4 分钟 29 秒
-
(已锁定)
Creating an add comment form8 分钟 26 秒
-
(已锁定)
-
-
-