we can place the following variables into jsx with {}
strintfloatsarrays []functions()
import './App.css';
function App() {
const title = 'Welcom to the new blog'
const likes = 50
return (
<div className="App">
<div className="content">
<h1>{title}</h1>
<p>likes {likes} times</p>
<p> { 10 }</p>
<p> { [1,2,3,4] }</p>
<p> { Math.random() * 100 }</p>
</div>
</div>
);
}
export default App;
The same can be done with attributes
import './App.css';
function App() {
const title = 'Welcom to the new blog'
const googleLink = 'https://google.com'
return (
<div className="App">
<div className="content">
<h1>{title}</h1>
<a href={ googleLink }>google</a>
</div>
</div>
);
}
export default App;
boolean and objects cannot be inserted the same way
import './App.css';
function App() {
const title = 'Welcom to the new blog'
const likes = 50
const person = {name: 'mario',age: 30}
return (
<div className="App">
<div className="content">
<h1>{title}</h1>
<p>likes {likes} times</p>
<p>{ person }
</div>
</div>
);
}
export default App;