After compilation, JSX expressions become regular JavaScript objects.
在编译以后,JSX表达式变成了正常JavaScript对象。
This means that you can use JSX inside of if statements and for loops, assign it to variables, accept it as arguments, and return it from functions:
那就意味你可以在if和for的内部使用JSX,把它赋值给变量,把它当着参数去使用,从一个函数里输出它:
function getGreeting(user) {
if (user) {
return <h1>Hello, {formatName(user)}!</h1>;
}
return <h1>Hello, Stranger.</h1>
}