Skip to content

Latest commit

 

History

History
43 lines (39 loc) · 704 Bytes

JSX.md

File metadata and controls

43 lines (39 loc) · 704 Bytes

JavaScript + XML (HTML)

function App() {
  return (
    <div id="container">
      <h2 className="note">Let's get started!</h2>
      <h2 className="note">Let's get started!</h2>
    </div>
  )
}

the jsx will be parsed as:

return React.createElement(
  'div', // tag name
  { id: 'container' }, // attributes
  // child elements
  React.createElement(
    'h2',
    { className: 'note' },
    `Let's get started!`
  ),
  React.createElement(
    'h2',
    { className: 'note' },
    `Let's get started!`
  )
)

JSX can also be stored as a variable!

/* we can store JSX in a variable! */
let content = <p>No Expenses Found!</p>

return (
  <div>
    {content}
  </div>
)