JSX in React Explained: What It Is and How to Use It Effectively
JSX is a JavaScript syntax extension for building React elements with HTML-like syntax inside your JavaScript code.
Can React Work Without JSX?
Section titled “Can React Work Without JSX?”Yes. React can work independently of JSX. However, JSX makes it easier to create user interfaces (UI).
In other words, whatever you can do with JSX, you can do the same with plain JavaScript. For instance, consider the two examples below. The first includes JSX syntax, while the second is regular JavaScript syntax.
Example 1: Creating React element with JSX
Section titled “Example 1: Creating React element with JSX”function MyBio() { return <h1>My name is Oluwatobi.</h1>;}const root = ReactDOM.createRoot(document.getElementById("root"));root.render(<MyBio />);<!DOCTYPE html><html lang="en-US"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <title>MyBio App</title> <script src="https://unpkg.com/react@18/umd/react.development.js"></script> <script src="https://unpkg.com/react-dom@18/umd/react-dom.development.js"></script> <script src="https://unpkg.com/@babel/standalone/babel.min.js"></script> </head> <body> <div id="root"></div> <script type="text/babel" src="MyBio.js"></script> </body></html>