mirror of
https://github.com/kou029w/_.git
synced 2025-02-07 09:38:46 +00:00
refactor: Stateless Functional Componentに変更
This commit is contained in:
parent
535ab0cd42
commit
9bea9c2e25
2 changed files with 39 additions and 47 deletions
|
@ -1,10 +1,7 @@
|
||||||
import { Component } from "react";
|
export default ({ activity }) => {
|
||||||
|
const kaburiActivity = activity.filter(a => a.ch === "kaburi");
|
||||||
export default class extends Component {
|
const count = kaburiActivity.length;
|
||||||
render() {
|
const time = kaburiActivity
|
||||||
const activity = this.props.activity.filter(a => a.ch === "kaburi");
|
|
||||||
const count = activity.length;
|
|
||||||
const time = activity
|
|
||||||
.map(a => a.endTime - a.startTime)
|
.map(a => a.endTime - a.startTime)
|
||||||
.reduce((a, c) => a + c, 0);
|
.reduce((a, c) => a + c, 0);
|
||||||
|
|
||||||
|
@ -16,5 +13,4 @@ export default class extends Component {
|
||||||
<dd>{time}</dd>
|
<dd>{time}</dd>
|
||||||
</dl>
|
</dl>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
}
|
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
import { Component } from "react";
|
export default ({ activity }) => {
|
||||||
|
const leftActivity = activity
|
||||||
export default class extends Component {
|
|
||||||
render() {
|
|
||||||
const leftActivity = this.props.activity
|
|
||||||
.filter(a => a.ch === "l")
|
.filter(a => a.ch === "l")
|
||||||
.map(a => a.endTime - a.startTime)
|
.map(a => a.endTime - a.startTime)
|
||||||
.reduce((a, c) => a + c, 0);
|
.reduce((a, c) => a + c, 0);
|
||||||
const rightActivity = this.props.activity
|
const rightActivity = activity
|
||||||
.filter(a => a.ch === "r")
|
.filter(a => a.ch === "r")
|
||||||
.map(a => a.endTime - a.startTime)
|
.map(a => a.endTime - a.startTime)
|
||||||
.reduce((a, c) => a + c, 0);
|
.reduce((a, c) => a + c, 0);
|
||||||
|
@ -25,5 +22,4 @@ export default class extends Component {
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue