refactored
This commit is contained in:
parent
1d48e78d7f
commit
3864c11b9b
4 changed files with 35 additions and 23 deletions
|
|
@ -1,26 +1,5 @@
|
||||||
const Header = (props) => {
|
import Header from "./components/Header";
|
||||||
return <h1>{props.course}</h1>;
|
import Content from "./components/Content";
|
||||||
};
|
|
||||||
|
|
||||||
const Part = (props) => {
|
|
||||||
return (
|
|
||||||
<p>
|
|
||||||
{props.partName} {props.exerciseCount}
|
|
||||||
</p>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const Content = (props) => {
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
{props.sections.map((section) => {
|
|
||||||
return (
|
|
||||||
<Part partName={section.part} exerciseCount={section.exerciseCount} />
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const App = () => {
|
const App = () => {
|
||||||
const course = {
|
const course = {
|
||||||
|
|
@ -38,6 +17,10 @@ const App = () => {
|
||||||
part: "State of a component",
|
part: "State of a component",
|
||||||
exerciseCount: 14,
|
exerciseCount: 14,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
part: "An extra part I added just like that",
|
||||||
|
exerciseCount: 1,
|
||||||
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
15
parts/2/courseExercise/src/components/Content.jsx
Normal file
15
parts/2/courseExercise/src/components/Content.jsx
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
import Part from "./Part";
|
||||||
|
|
||||||
|
const Content = (props) => {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{props.sections.map((section) => {
|
||||||
|
return (
|
||||||
|
<Part key={section.part} partName={section.part} exerciseCount={section.exerciseCount} />
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Content;
|
||||||
5
parts/2/courseExercise/src/components/Header.jsx
Normal file
5
parts/2/courseExercise/src/components/Header.jsx
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
const Header = (props) => {
|
||||||
|
return <h1>{props.course}</h1>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Header;
|
||||||
9
parts/2/courseExercise/src/components/Part.jsx
Normal file
9
parts/2/courseExercise/src/components/Part.jsx
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
const Part = (props) => {
|
||||||
|
return (
|
||||||
|
<p>
|
||||||
|
{props.partName} {props.exerciseCount}
|
||||||
|
</p>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Part;
|
||||||
Loading…
Add table
Add a link
Reference in a new issue