React: Difference between revisions

From bibbleWiki
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="php">
=Maps=
<?php
<source lang="babel" line="line">
    v = "string";   // sample initialization
 
?>
// Only do this if items have no stable IDs
html text
<?php
const todo = ["fix", "syntax", "highlighting"];
    echo v;        // end of php code
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>
);