aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIbrahim Mkusa <ibrahimmkusa@gmail.com>2023-04-26 19:49:43 -0400
committerIbrahim Mkusa <ibrahimmkusa@gmail.com>2023-04-26 19:49:43 -0400
commitf4ab316389d8a8238a539668fdfef25e7b27e27f (patch)
tree6ad5855deaf9db979ebb31a3e5d938c899db58a7
parentb7f1995778f2982c81e85111f76fa0bf8fb71ee8 (diff)
ex1.10 refactored Display->StaticLine
-rw-r--r--part1/unicafe/src/App.js16
1 files changed, 9 insertions, 7 deletions
diff --git a/part1/unicafe/src/App.js b/part1/unicafe/src/App.js
index b583060..d2ef92b 100644
--- a/part1/unicafe/src/App.js
+++ b/part1/unicafe/src/App.js
@@ -8,12 +8,14 @@ const Button = (props) => {
)
}
-const Display = (props) => {
+const StatisticLine = (props) => {
return (
<p>{props.text} {props.count}</p>
)
}
+
+
const Statistics = (props) => {
const good = props.good
const bad = props.bad
@@ -26,12 +28,12 @@ const Statistics = (props) => {
const positive_percent = (good/total) * 100
return (
<>
- <Display text="good" count={good} />
- <Display text="neutral" count={bad} />
- <Display text="bad" count={bad} />
- <Display text="all" count={total} />
- <Display text="average" count={average} />
- <Display text="positive(%)" count={positive_percent} />
+ <StatisticLine text="good" count={good} />
+ <StatisticLine text="neutral" count={bad} />
+ <StatisticLine text="bad" count={bad} />
+ <StatisticLine text="all" count={total} />
+ <StatisticLine text="average" count={average} />
+ <StatisticLine text="positive(%)" count={positive_percent} />
</>
)
}