Completed 2.1

This commit is contained in:
2021-08-27 13:27:51 +07:00
parent df1045f79d
commit 755cf0fae8
3 changed files with 44 additions and 21952 deletions
+23 -21943
View File
File diff suppressed because it is too large Load Diff
+18 -9
View File
@@ -2,28 +2,36 @@ import React from 'react'
const App = () => { const App = () => {
const course = { const course = {
id: 1,
name: 'Half Stack application development', name: 'Half Stack application development',
parts: [ parts: [
{ {
name: 'Fundamentals of React', name: 'Fundamentals of React',
exercises: 10 exercises: 10,
id: 1
}, },
{ {
name: 'Using props to pass data', name: 'Using props to pass data',
exercises: 7 exercises: 7,
id: 2
}, },
{ {
name: 'State of a component', name: 'State of a component',
exercises: 14 exercises: 14,
id: 3
} }
] ]
} }
return <Course course={course} />
}
const Course = ({course}) => {
return ( return (
<div> <div>
<Header course={course} /> <Header course={course} />
<Content part={course.parts} /> <Content part={course.parts} />
<Total part={course.parts} /> {/*<Total part={course.parts} >*/}
</div> </div>
) )
} }
@@ -35,11 +43,12 @@ const Header = (props) => {
} }
const Content = (props) => { const Content = (props) => {
//console.log(props)
return ( return (
<div> <div>
<Part part={props.part[0]} /> {props.part.map(part =>
<Part part={props.part[1]} /> <Part key={part.id} part={part} />
<Part part={props.part[2]} /> )}
</div> </div>
) )
@@ -51,10 +60,10 @@ const Part = (props) => {
) )
} }
const Total = (props) => { /*const Total = (props) => {
return ( return (
<p>Number of exercises {props.part[0].exercises + props.part[1].exercises + props.part[2].exercises}</p> <p>Number of exercises {props.part[0].exercises + props.part[1].exercises + props.part[2].exercises}</p>
) )
} }*/
export default App export default App
+3
View File
@@ -0,0 +1,3 @@
{
"lockfileVersion": 1
}