blob: 70f0e8b77bff1e6366980a101649ddc1cf5b9847 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
const Header = (props) => {
return (
<h1>{props.name}</h1>
)
}
const Part = (props) => {
//// props.part is an object containing name and exercises
return (
<p>
{props.part.name} {props.part.exercises}
</p>
)
}
const Total = (props) => {
return (
<p>Number of exercises {props.one + props.two + props.three}</p>
)
}
const App = () => {
const course = 'Half Stack application development'
const part1 = {
name: 'Fundamentals of React',
exercises: 10
}
const part2 = {
name: 'Using props to pass data',
exercises: 7
}
const part3 = {
name: 'State of a component',
exercises: 14
}
return (
<div>
<Header name={course}/>
<Part part={part1} />
<Part part={part2} />
<Part part={part3} />
<Total one={part1.exercises} two={part2.exercises} three={part3.exercises} />
</div>
)
}
export default App
|