name
and then use it inside JSX by wrapping it in curly braces:2 + 2
, user.firstName
, or formatName(user)
are all valid JavaScript expressions.formatName(user)
, into an <h1>
element.if
statements and for
loops, assign it to variables, accept it as arguments, and return it from functions:/>
, like XML:React.createElement()
calls.React.createElement()
performs a few checks to help you write bug-free code but essentially it creates an object like this:Tip:We recommend using the “Babel” language definition for your editor of choice so that both ES6 and JSX code is properly highlighted.