what is jsx

 JSX allows us to write HTML in React.

JSX makes it easier to write and add HTML in React.


two ways to create html

directly and inderectly

with jsx

import React from 'react';
import ReactDOM from 'react-dom/client';

const myElement = React.createElement('h1', {}, 'I do not use JSX!');

const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(myElement);


=

without jsx

import React from 'react';
import ReactDOM from 'react-dom/client';

const myElement = React.createElement('h1', {}, 'I do not use JSX!');

const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(myElement);


==


we can evaluate expression using {}

const myElement = <h1>React is {5 + 5} times better with JSX</h1>;

No comments:

Post a Comment

Event listening in react

 How we can listen to som eevents some envents fire like click or automatically user enters into input button , that is event on word type i...