main jsx attribute code example
Example 1: create react element with string
mport React from 'react'
const MyComponent = 'div'
function App() {
return (
<div>
<h1>Hello</h1>
<hr />
<MyComponent>
<h3>I am inside a {'<div />'} element</h3>
</MyComponent>
</div>
)
}
Example 2: javascript in jsx
const name = 'Josh Perez';
const element = <h1>Hello, {name}</h1>;
//notice the use of {...} to jump from jsx to javascript.
ReactDOM.render(
element,
document.getElementById('root')
);