JSX Rules
- JSX syntax
- To make our life easier as it returns html
- Always return single element. you cannot do as below
- const App = () => {Â return (Â Â <h2> header </h2>Â Â <h3> header </h3>Â )};Â
- You can wrap up with divÂ
- const App = () => {Â return (Â Â <div>Â Â Â <h2> header </h2>Â Â Â <h3> header </h3>Â Â </div>Â );};
- You can wrap with fragment which doesnt add extra node
- const App = () => {Â return (Â Â <React.Fragment>Â Â Â <h2> header </h2>Â Â Â <h3> header </h3>Â Â </React.Fragment>Â );};
- The short syntax of React.Fragmentconst App = () => {Â return (Â Â <>Â Â Â <h2> header </h2>Â Â Â <h3> header </h3>Â Â </>Â );};