Exercise 1.5

This commit is contained in:
Augusto Gunsch 2022-06-12 11:56:58 +02:00
parent 565f86e6fd
commit a05a300c1e
1 changed files with 24 additions and 22 deletions

View File

@ -1,16 +1,16 @@
const Header = (props) => ( const Header = (props) => (
<h1>{props.course}</h1> <h1>{props.course.name}</h1>
) )
const Part = (props) => ( const Part = (props) => (
<p>{props.part} {props.exercise}</p> <p>{props.part.name} {props.part.exercises}</p>
) )
const Content = (props) => ( const Content = (props) => (
<div> <div>
<Part part={props.parts[0].name} exercise={props.parts[0].exercises} /> <Part part={props.parts[0]} />
<Part part={props.parts[1].name} exercise={props.parts[1].exercises} /> <Part part={props.parts[1]} />
<Part part={props.parts[2].name} exercise={props.parts[2].exercises} /> <Part part={props.parts[2]} />
</div> </div>
) )
@ -19,27 +19,29 @@ const Total = (props) => (
) )
const App = () => { const App = () => {
const course = 'Half Stack application development' const course = {
const parts = [ name: 'Half Stack application development',
{ parts: [
name: 'Fundamentals of React', {
exercises: 10 name: 'Fundamentals of React',
}, exercises: 10
{ },
name: 'Using props to pass data', {
exercises: 7 name: 'Using props to pass data',
}, exercises: 7
{ },
name: 'State of a component', {
exercises: 14 name: 'State of a component',
} exercises: 14
] }
]
}
return ( return (
<div> <div>
<Header course={course} /> <Header course={course} />
<Content parts={parts}/> <Content parts={course.parts}/>
<Total total={parts} /> <Total parts={course.parts} />
</div> </div>
) )
} }