课程: Learning Full-Stack JavaScript Development: MongoDB, Node, and React
今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
React’s key for items in a list
课程: Learning Full-Stack JavaScript Development: MongoDB, Node, and React
React’s key for items in a list
- [Instructor] Let's now talk about that error in the consult that you see. Each child in a list should have a unique key prop. This is a React requirement. Every time we render a list like this dynamically we need to tell React what identifies an element in the list. React uses this unique identifier of an element to optimize the rendering of this list when things are updated. So for example, assume that we have the capability of drag and drop here, we can reorder the list. We're not going to do that. This is just an example to understand this key prop. If we can drag and drop these lists react will re-render them right without an ID. React will not know what is being dragged and dropped and will most likely need to re-render the entire list. But with an ID, react can say, Oh you took the second element and placed it on a third. So it can optimize the re-rendering here because now it knows what is going on. We specify…
内容
-
-
-
-
-
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 秒
-
-
-