什么是JSX?官方定义:JSX是React.createElement(components,props,...children)函数的语法糖ClickMe上面的函数会被编译为下面代码:React.createElement(Mybutton,{color:'blue',shadowSize:2},'ClickMe')打开React源码,找到createElement函数:functioncreateElement(type,config,children){var道具名称;/提取保留名称varprops={};变量键=空;变种参考=空;变种自我=空;变量源=空;if(config!=null){if(hasValidRef(config)){ref=config.ref;{warnIfStringRefCannotBeAutoConverted(config);}}if(hasValidKey(config)){{checkKeyStringCoercion(config.key);}key=''+config.key;}self=config.__self===未定义?空:config.__self;来源=config.__来源===未定义?空:配置.__源;//剩余的属性被添加到一个新的props对象中for(propNameinconfig){if(hasOwnProperty.call(config,propName)&&!RESERVED_PROPS.hasOwnProperty(propName)){props[propName]=config[propName];}}}//Children可以有多个参数,这些参数会被转移到//新分配的props对象上。varchildrenLength=arguments.length-2;if(childrenLength===1){props.children=children;}elseif(childrenLength>1){varchildArray=Array(childrenLength);for(vari=0;i1){varchildArray=Array(childrenLength);for(vari=0;i1){constchildArray=Array(childrenLength);for(leti=0;i