File tree Expand file tree Collapse file tree 1 file changed +15
-10
lines changed
atcoder-problems-frontend/src/pages/TablePage Expand file tree Collapse file tree 1 file changed +15
-10
lines changed Original file line number Diff line number Diff line change 1
- import React , { useState } from "react" ;
1
+ import React , { useMemo , useState } from "react" ;
2
2
import { List } from "immutable" ;
3
3
import {
4
4
useContests ,
@@ -82,15 +82,20 @@ export const TablePage: React.FC<OuterProps> = (props) => {
82
82
props . userId
83
83
) ;
84
84
85
- const selectedContestCategories = [ activeTab ] ;
86
- const likeContestCategory = getLikeContestCategory ( activeTab ) ;
87
- if ( likeContestCategory && mergeLikeContest ) {
88
- selectedContestCategories . push ( likeContestCategory ) ;
89
- }
90
- const filteredContests =
91
- contests ?. filter ( ( c ) =>
92
- selectedContestCategories . includes ( classifyContest ( c ) )
93
- ) ?? [ ] ;
85
+ const filteredContests = useMemo ( ( ) => {
86
+ if ( ! contests ) {
87
+ return [ ] ;
88
+ }
89
+ return contests . filter ( ( contest ) => {
90
+ const contestType = classifyContest ( contest ) ;
91
+ if ( contestType === activeTab ) {
92
+ return true ;
93
+ }
94
+ return (
95
+ mergeLikeContest && getLikeContestCategory ( activeTab ) === contestType
96
+ ) ;
97
+ } ) ;
98
+ } , [ contests , activeTab , mergeLikeContest ] ) ;
94
99
95
100
return (
96
101
< div >
You can’t perform that action at this time.
0 commit comments