refactored

This commit is contained in:
Pablo Martin 2025-05-20 16:40:29 +02:00
parent 1d48e78d7f
commit 3864c11b9b
4 changed files with 35 additions and 23 deletions

View file

@ -1,26 +1,5 @@
const Header = (props) => {
return <h1>{props.course}</h1>;
};
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} />
);
})}
</>
);
};
import Header from "./components/Header";
import Content from "./components/Content";
const App = () => {
const course = {
@ -38,6 +17,10 @@ const App = () => {
part: "State of a component",
exerciseCount: 14,
},
{
part: "An extra part I added just like that",
exerciseCount: 1,
},
],
};

View 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;

View file

@ -0,0 +1,5 @@
const Header = (props) => {
return <h1>{props.course}</h1>;
};
export default Header;

View file

@ -0,0 +1,9 @@
const Part = (props) => {
return (
<p>
{props.partName} {props.exerciseCount}
</p>
);
};
export default Part;