completed exercise 1.1
This commit is contained in:
parent
b11136fc9d
commit
c118246961
12 changed files with 2778 additions and 2 deletions
58
parts/1/exerciseApp/src/App.jsx
Normal file
58
parts/1/exerciseApp/src/App.jsx
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
const Header = (props) => {
|
||||
return <h1>{props.course}</h1>
|
||||
}
|
||||
|
||||
const Content = (props) => {
|
||||
return (
|
||||
<>
|
||||
{props.sections.map((section) => {
|
||||
return <p>{section.part} {section.exerciseCount}</p>
|
||||
})}
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
const Total = (props) => {
|
||||
return (
|
||||
<>
|
||||
<p>Number of exercises {props.totalExerciseCount}</p>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
const App = () => {
|
||||
const course = 'Half Stack application development'
|
||||
const part1 = 'Fundamentals of React'
|
||||
const exercises1 = 10
|
||||
const part2 = 'Using props to pass data'
|
||||
const exercises2 = 7
|
||||
const part3 = 'State of a component'
|
||||
const exercises3 = 14
|
||||
|
||||
const sections = [
|
||||
{
|
||||
part: part1,
|
||||
exerciseCount: exercises1
|
||||
},
|
||||
{
|
||||
part: part2,
|
||||
exerciseCount: exercises2
|
||||
},
|
||||
{
|
||||
part: part3,
|
||||
exerciseCount: exercises3
|
||||
},
|
||||
|
||||
]
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Header course={course}/>
|
||||
<Content sections={sections}/>
|
||||
<Total totalExerciseCount={exercises1 + exercises2 + exercises3}/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default App
|
||||
5
parts/1/exerciseApp/src/main.jsx
Normal file
5
parts/1/exerciseApp/src/main.jsx
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
import ReactDOM from 'react-dom/client'
|
||||
|
||||
import App from './App'
|
||||
|
||||
ReactDOM.createRoot(document.getElementById('root')).render(<App />)
|
||||
Loading…
Add table
Add a link
Reference in a new issue