课程: Learning Full-Stack JavaScript Development: MongoDB, Node, and React
今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Rendering a list of items
课程: Learning Full-Stack JavaScript Development: MongoDB, Node, and React
Rendering a list of items
- We created a mock API endpoint, configured express to use it and allow cross origin requests to it. And we're fetching this mock API endpoint right here before we render the React application. How do we use this data in React? We have options. We can delay the rendering of the app until we have the data. Let's start with that option. All we need to do for that is move this route dot render call to the Axios promise handler because in here, we're done with the network call and we have the data. To make the app component aware of that data, we can pass it as props. Let me pass it here as an object. Name it initial data expression to pass in a dynamic value. And in here I'll pass in an object with contests coming from response.data. The mocked API call we created returns an array of contests directly. I like to have the API calls always return an object with named elements. So, instead of returning contests…
内容
-
-
-
-
-
Creating a mock API endpoint5 分钟 52 秒
-
(已锁定)
Using an API endpoint from the browser9 分钟 2 秒
-
(已锁定)
Rendering a list of items8 分钟 47 秒
-
(已锁定)
React’s key for items in a list4 分钟 29 秒
-
(已锁定)
Fetching data while React is rendering8 分钟 5 秒
-
(已锁定)
Server-side rendering of the root path7 分钟 41 秒
-
(已锁定)
Sharing data between server and client5 分钟 1 秒
-
(已锁定)
Fetching data from MongoDB6 分钟 17 秒
-
-
-