Search code examples
typescriptreactjstsx

Can <i></i> tag be a self closing tag in JSX?


I followed Airbnb React/JSX style guide, it said that "Always self-close tags that have no children".

Is it also be valid for <i></i> tag that generally has no children? Can it be written as <i className="fa fa-info" /> in JSX?


Solution

  • Yes, you can, I just put together a codesandbox and it appears to be working.

    https://codesandbox.io/s/XoMNlLzpo

    enter image description here