diff --git a/app/components/County.jsx b/app/components/County.jsx index 6148715..fe26498 100644 --- a/app/components/County.jsx +++ b/app/components/County.jsx @@ -1,4 +1,4 @@ -import { useMemo, useState } from "react"; +import { useState } from "react"; export function County({ county }) { const [sort, setSort] = useState({ @@ -6,31 +6,6 @@ export function County({ county }) { type: "desc", }); - const sortMemo = useMemo( - () => - county.players.sort((a, b) => { - if (sort.field === "rank") - return sort.type === "desc" - ? parseInt(a.rank) - parseInt(b.rank) - : parseInt(b.rank) - parseInt(a.rank); - if (sort.field === "score") - return sort.type === "desc" ? a.score - b.score : b.score - a.score; - if (sort.field === "SS") - return sort.type === "desc" - ? a.SSranks - b.SSranks - : b.SSranks - a.SSranks; - if (sort.field === "S") - return sort.type === "desc" - ? a.Sranks - b.Sranks - : b.Sranks - a.Sranks; - if (sort.field === "A") - return sort.type === "desc" - ? a.Aranks - b.Aranks - : b.Aranks - a.Aranks; - }), - [sort.field, sort.type, county.players] - ); - return (
  • - - {index + 1}. - - - - {player.playerName} - - - - {player.rank ? `#${player.rank}` : "-"} - - - {new Intl.NumberFormat().format(player.score)} - - - {player.SSranks} - - - {player.Sranks} - - - {player.Aranks} - - - ))} + {county.players + .sort((a, b) => { + if (sort.field === "rank") + return sort.type === "desc" + ? parseInt(a.rank) - parseInt(b.rank) + : parseInt(b.rank) - parseInt(a.rank); + if (sort.field === "score") + return sort.type === "desc" + ? a.score - b.score + : b.score - a.score; + if (sort.field === "SS") + return sort.type === "desc" + ? a.SSranks - b.SSranks + : b.SSranks - a.SSranks; + if (sort.field === "S") + return sort.type === "desc" + ? a.Sranks - b.Sranks + : b.Sranks - a.Sranks; + if (sort.field === "A") + return sort.type === "desc" + ? a.Aranks - b.Aranks + : b.Aranks - a.Aranks; + }) + .map((player, index) => ( + + + {index + 1}. + + + + {player.playerName} + + + + {player.rank ? `#${player.rank}` : "-"} + + + {new Intl.NumberFormat().format(player.score)} + + + {player.SSranks} + + + {player.Sranks} + + + {player.Aranks} + + + ))} ) : (