React: Difference between revisions

805 bytes added ,  1 October 2019
Line 1,475: Line 1,475:
= React with JSX =
= React with JSX =


== React elements as JSX ==
=== Nested components ===
<source lang="html">
<IngredientsList>
  <Ingredient />
  <Ingredient />
  <Ingredient />
</IngredientsList>
</source>
=== ClassName ===
Since <code>class</code> is a reserved word in JavaScript, className is used to define the class attribute.
=== JavaScript Expressions ===
<source lang="js">
<h1>{title}</h1>
<input type="checkbox" defaultChecked="{false}" />
</source>
=== Evaluation ===
<source lang="js">
<h1>{"Hello" + title}</h1>
<h1>{title.toLowerCase().replace}</h1>
function appendTitle({ title }) {
  console.log(`${title} is great!`);
}
</source>
=== Mapping Arrays with JSX ===
<source lang="js">
<ul>
  {props.ingredients.map((ingredient, i) => (
    <li key="{i}">{ingredient}</li>
  ))}
</ul>
</source>
== Babel ==


= React State Management =
= React State Management =