Use curly braces {} to embed JS expressions:
{} is JS evaluated at runtimeconst name ="Hen"
const element =<h1>Hello, {name}!</h1>
const a =5
const b =10
const element =<p>{a} + {b} = {a + b}</p>
() optional but recommendedfunction App() {
return (
<div>
<h1>My App</h1>
<Welcome name="Hen" />
<p>JSX is awesome!</p>
</div>
)
}
<div> just for that.<React.Fragment>:import React from 'react'
function App() {
return (
<React.Fragment>
<h1>Title</h1>
<p>Some text</p>
</React.Fragment>
)
}
export default App
<>:function App() {
return (
<>
<h1>Title</h1>
<p>Some text</p>
</>
)
}