JSX allow us to write HTML elements in JavaScript and place them in the DOM (Document Object Model) without any createElement() and / or appendChild() methods.
JSX convers HTML tags into react elements
EXAMPLES
with JSX
const elem = <h1> I love JSX!</h1>;
ReactDOM.render(elem, document.getElementById('root'));
without JSX
const elem = React.createElement('h1', {}, 'I do not use JSX!');
ReactDOM.render(elem, document.getElementById('root'));
Expressions
The expressions can be a React variable, or property, or any other valid JS expression
const elem = <h1>{5 + 5} is 10</h1>
JSX convers HTML tags into react elements
EXAMPLES
with JSX
const elem = <h1> I love JSX!</h1>;
ReactDOM.render(elem, document.getElementById('root'));
without JSX
const elem = React.createElement('h1', {}, 'I do not use JSX!');
ReactDOM.render(elem, document.getElementById('root'));
Expressions
The expressions can be a React variable, or property, or any other valid JS expression
const elem = <h1>{5 + 5} is 10</h1>
댓글
댓글 쓰기