JSX is a syntax extension that allows you to write HTML-like code inside JavaScript.
const element = <h1>Hello, world!</h1>;
// equivalent to:
const element = React.createElement('h1', null, 'Hello, world!');
Remember:
- JSX must return one parent element → use
div
or<>...</>
(Fragment). - You can embed JavaScript expressions using
{}
.
Để lại một bình luận