import React from "react";
const Hello = () => {
// JSX
return (
<div id="id" className="class">
<h1>Hello World</h1>
</div>
)
// without using JSX
return React.createElement(
'div',
{id: 'id', className: 'class'},
React.createElement('hi', null, 'Hello World')
)
}
export default Hello;
Basically, each JSX element is just syntactic sugar for calling React.createElement
. And that is why we have to import the react library when we use JSX.
import React from "react";
Class
→ className
for
→ htmlFor
onclick
→ onClick
tabindex
→ tabIndex
💁 className
→ class
React Fire: Modernizing React DOM