Capítulo 14 de 116
Curly braces {} are the only escape hatch from JSX back into plain JavaScript — they work in exactly two positions (as tag text content, or immediately after = in an attribute), and everything else follows from that.
alt="Gregorio Y. Zara". To use a JS value instead, swap quotes for curly braces: alt={description}.{} — a variable, a function call ({formatDate(today)}), a computed string, etc. Statements (like if) are not expressions and don't work directly inside {}.<h1>{name}'s Todos</h1>) or as an attribute value right after = (src={avatar}). <{tag}> and src="{avatar}" (quotes around the braces) are both invalid/wrong.style={{ backgroundColor: 'black' }} is a plain JS object literal { backgroundColor: 'black' } passed through the ordinary {} JSX escape hatch. Inline style properties are camelCase (backgroundColor, not background-color).<h1>{person}</h1> where person is an object fails with "Objects are not valid as a React child" — React needs a string/number/element, so you must reach into the object ({person.name}) first.const person = {
name: 'Gregorio Y. Zara',
theme: { backgroundColor: 'black', color: 'pink' }
};
<div style={person.theme}>
<h1>{person.name}'s Todos</h1>
</div>
{} escape hatch — style={person.theme} (object) and {person.name} (string).{} always means "evaluate this as JavaScript" — never wrap it in quotes, or it becomes a literal string instead.style={{...}} isn't magic — it's just an object literal nested inside the normal curly-brace escape hatch, so any JS object you already have (e.g. person.theme) works the same way.{} syntax operates within.{} is exactly how prop values get passed down from JSX.