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

server laravel application

 asset_url = domain/public chmod -R 755 public/admin/ composer dump-autoload get the application from hostinger