File tree Expand file tree Collapse file tree 2 files changed +13
-11
lines changed
atcoder-problems-frontend/src Expand file tree Collapse file tree 2 files changed +13
-11
lines changed Original file line number Diff line number Diff line change 1- import React from "react" ;
1+ import React , { useMemo } from "react" ;
22import { Row , ButtonGroup , Button } from "reactstrap" ;
33import {
44 ContestCategories ,
55 ContestCategory ,
66} from "../../utils/ContestClassifier" ;
7- import { LikeContestCategories } from "../../utils/LikeContestUtils" ;
7+ import { isLikeContest } from "../../utils/LikeContestUtils" ;
88
99interface Props {
1010 active : ContestCategory ;
@@ -15,19 +15,18 @@ interface Props {
1515export const TableTabButtons : React . FC < Props > = ( props ) => {
1616 const { active, setActive, mergeLikeContest } = props ;
1717
18- const filterCategories = ( contestCategories : readonly ContestCategory [ ] ) => {
19- if ( ! mergeLikeContest ) return contestCategories ;
20-
21- return contestCategories . filter (
22- ( category ) => ! LikeContestCategories . includes ( category )
18+ const filteredCategories = useMemo ( ( ) => {
19+ return ContestCategories . filter (
20+ ( category ) => ! mergeLikeContest || ! isLikeContest ( category )
2321 ) ;
24- } ;
22+ } , [ mergeLikeContest ] ) ;
23+
2524 return (
2625 < Row >
2726 < ButtonGroup className = "table-tab" >
28- { filterCategories ( ContestCategories ) . map ( ( category , i ) => (
27+ { filteredCategories . map ( ( category ) => (
2928 < Button
30- key = { String ( i ) }
29+ key = { category }
3130 color = "secondary"
3231 onClick = { ( ) : void => {
3332 setActive ( category ) ;
Original file line number Diff line number Diff line change @@ -15,8 +15,11 @@ export const getLikeContestCategory = (
1515 }
1616} ;
1717
18- export const LikeContestCategories : readonly ContestCategory [ ] = [
18+ const LikeContestCategories : readonly ContestCategory [ ] = [
1919 "ABC-Like" ,
2020 "ARC-Like" ,
2121 "AGC-Like" ,
2222] ;
23+ export const isLikeContest = ( category : ContestCategory ) => {
24+ return LikeContestCategories . includes ( category ) ;
25+ } ;
You can’t perform that action at this time.
0 commit comments