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

How to host application on server new way

 copy the htacess from public to root copy the server.php from public to root but rename to index.php htacess <IfModule mod_rewrite.c>...