What are the rules for closing JSX tags?

Posted . Visible to the public.
  • Any JSX element can be written with a self-closing tag, and every element must be closed. The line-break tag, for example, must always be written as <br /> in order to be valid JSX that can be transpiled.

  • A <div>, on the other hand, can be written as <div /> or <div></div>. The difference is that in the first syntax version there is no way to include anything in the <div />. This syntax is useful when rendering React components.

Daniel
Last edit
Daniel
Keywords
react
Posted by Daniel to Dev (2018-10-06 08:07)