React: Difference between revisions
Jump to navigation
Jump to search
Line 2: | Line 2: | ||
=Variables= | =Variables= | ||
<source lang="babel" line="line"> | <source lang="babel" line="line"> | ||
const myVar = ( | const myVar = ( | ||
Line 9: | Line 8: | ||
</source> | </source> | ||
<source lang=" | =Maps= | ||
<source lang="babel" line="line"> | |||
// Only do this if items have no stable IDs | |||
< | const todo = ["fix", "syntax", "highlighting"]; | ||
const todoItems = todos.map((todo, index) => | |||
<li key={index}> | |||
</source> | {todo.text} | ||
</li> | |||
);</source> |
Revision as of 05:38, 23 October 2019
Quick Reference
Variables
const myVar = (
<h1>Love it</h1>
);
Maps
// Only do this if items have no stable IDs
const todo = ["fix", "syntax", "highlighting"];
const todoItems = todos.map((todo, index) =>
<li key={index}>
{todo.text}
</li>
);