课程: Learning Full-Stack JavaScript Development: MongoDB, Node, and React
今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Fetching data while React is rendering
课程: Learning Full-Stack JavaScript Development: MongoDB, Node, and React
Fetching data while React is rendering
- [Narrator] To fetch data for the project so far, we used this method, fetch and then render. This sequence is not ideal, making React wait on the fetch. It would be better if we let React do its rendering while the data is being fetched. And then when the data arrives, React can do a DOM update operation, that's slightly more efficient. There are a few methods to accomplish that, but the gist for all of them is to not make this dependency here. So we need to have React render the app right away, and we can use just an empty array of contests for the initial data. React will render fine with an empty list of contests. Then we take this fetch call and move it to the React component that needs the data. In this case, the contest list component. Ideally, we can have the data fetching start even before React renders the component. But for simplicity, I'll put the data fetching in a use effect call within the contest list…
内容
-
-
-
-
-
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 秒
-
-
-