2.2 JSX is an Expression Too JSX是一种表达式

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

Hello, {formatName(user)}!

;
   }
   return  

Hello, Stranger.


}

你可能感兴趣的:(2.2 JSX is an Expression Too JSX是一种表达式)