JSX in React JS
JSX is a syntax extension for JavaScript that allows you to write HTML-like code in your JavaScript files. JSX is compiled to regular JavaScript by Babel. Here's an example of JSX:
jsx
function Greeting(props) {
return <h1>Hello, {props.name}!</h1>;
}
ReactDOM.render(
<Greeting name="John" />,
document.getElementById('root')
);
In this example, the JSX syntax allows us to write HTML-like code in the return statement of the Greeting component.
No comments:
Post a Comment