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" ;
22import { List } from "immutable" ;
33import {
44 useContests ,
@@ -82,15 +82,20 @@ export const TablePage: React.FC<OuterProps> = (props) => {
8282 props . userId
8383 ) ;
8484
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 ] ) ;
9499
95100 return (
96101 < div >
You can’t perform that action at this time.
0 commit comments