Professional Documents
Culture Documents
Le02 (Comp)
Le02 (Comp)
2) open / edit app.js file then edit the content of the file in app part :
const App = () => (
<div>
<p>Hello world</p>
</div>
)
4) Again open / edit app.js file then edit the content of the file in app
part.
The function returns the value of the expression.
const App = () => {
return (
<div>
<p>Hello world</p>
</div>
)
}
5) save it and it will automatically start the server to dispaly the ouput in
browser.
-----------------------------------------------------------------------------------
---
Modify your component to be as follows and observe what happens in the
console:
1) open / edit app.js file then edit the content of the file in app part :
const App = () => {
console.log('Hello from component')
return (
<div>
<p>Hello world</p>
</div>
)
}
3) save it and it will automatically start the server to dispaly the ouput in
browser.
-----------------------------------------------------------------------------------
-----------
Dynamic Content -Component
1) open / edit app.js file then edit the content of the file in app part :
const App = () => {
const now = new Date()
const a = 10
const b = 20
return (
<div>
<p>Hello world, it is {now.toString()}</p>
<p>
{a} plus {b} is {a + b}
</p>
</div>
)
}
3) save it and it will automatically start the server to dispaly the ouput in
browser.
-----------------------------------------------------------------------------------
---------
1) open / edit app.js file then edit the content of the file in app part :
const App = () => {
const now = new Date()
const a = 10
const b = 20
return React.createElement(
'div',
null,
React.createElement(
'p', null, 'Hello world, it is ', now.toString()
),
React.createElement(
'p', null, a, ' plus ', b, ' is ', a + b
)
)
}
3) save it and it will automatically start the server to dispaly the ouput in
browser.
-----------------------------------------------------------------------------------
------------------
Multiple components
2) save it and it will automatically start the server to dispaly the ouput in
browser.
-----------------------------------------------------------------------------------
-------------------