01

作者: bestCindy | 来源:发表于2020-07-28 23:32 被阅读0次

section: what is react

  • the <div /> syntax is transformed at build time to React.createElement('div').
    for example
class ShoppingList extends React.Component {
  render() {
    return (
      <div className="shopping-list">
        <h1>Shopping List for {this.props.name}</h1>
        <ul>
          <li>Instagram</li>
          <li>WhatsApp</li>
          <li>Oculus</li>
        </ul>
      </div>
    );
  }
}

it's equivalent to

return React.createElement('div', {className: 'shopping-list'},
  React.createElement('h1', /* ... h1 children ... */),
  React.createElement('ul', /* ... ul children ... */)
);
  • the render() element should have return statement

相关文章

网友评论

      本文标题:01

      本文链接:https://www.haomeiwen.com/subject/wgccrktx.html