-
Notifications
You must be signed in to change notification settings - Fork 781
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Brush up docs, TOC, add section about keys.
- Loading branch information
1 parent
b906d1c
commit 1794706
Showing
12 changed files
with
151 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Keys | ||
|
||
Every time your application is rendered, a virtual node tree is created from scratch. | ||
|
||
Keys help identify which nodes were added, changed or removed from the new/old tree. | ||
|
||
Use keys to tell the render algorithm to re-order the children instead of mutating them. | ||
|
||
```jsx | ||
<ul> | ||
{urls.map((url, id) => ( | ||
<li key={id}> | ||
<img src={url} /> | ||
</li> | ||
))} | ||
</ul> | ||
``` | ||
|
||
For example, use keys to force an element to be created only once. | ||
|
||
```jsx | ||
<ul> | ||
<li key="hyper">Hyper</li> | ||
<li>Super</li> | ||
<li>Ultra</li> | ||
</ul> | ||
``` | ||
|
||
If new elements added to the list, the position of the keyed element will change. Using a key in this way, makes sure <samp>Hyper</samp> is always inserted in the right position instead of mutating its siblings. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.