jsx语法简介

实际上,JSX 仅仅只是 React.createElement(component, props, ...children) 函数的语法糖。

https://zh-hans.reactjs.org/docs/jsx-in-depth.html

<Provider store={this.state.store}>

 <Root />

</Provider>

return React.createElement(Provider, {

    store: this.state.store

  }, React.createElement(Root, null));

https://babeljs.io/repl/#?babili=false&browsers=&build=&builtIns=false&spec=false&loose=false&code_lz=GYVwdgxgLglg9mABACwKYBt1wBQEpEDeAUIogE6pQhlICQ9APAAplwBuMAJqmYgM5Q4FALwEoyGHwB0AgIZRUMwRQC-APiL1GAJThwoiAPQatDQy3ZceagNxEVRIA&debug=false&forceAllTransforms=false&shippedProposals=false&circleciRepo=&evaluate=false&fileSize=false&timeTravel=false&sourceType=module&lineWrap=true&presets=react&prettier=false&targets=&version=7.5.4&externalPlugins=

<MyButton color="blue" shadowSize={2}>

  Click Me

</MyButton>

React.createElement(

  MyButton,

  {color: 'blue', shadowSize: 2},

  'Click Me'

)

原文地址:https://www.cnblogs.com/feng9exe/p/11166033.html