-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix(hall-of-fame): fix bug in dynamic imports
- Loading branch information
1 parent
88e269d
commit 988e424
Showing
6 changed files
with
28 additions
and
21 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { useEffect, useState } from "react"; | ||
|
||
const usePastData = ({ round, ghostLegion, year = 2023 }) => { | ||
const [pastData, setPastData] = useState({}); | ||
|
||
useEffect(() => { | ||
const fetchPastLeaderboadData = async () => { | ||
let path = round == 1 ? "round1" : ghostLegion == true ? "ghost-legion" : "final"; | ||
const data = (await import(`../../data/annual-leaderboard/${year}/${path}.json`)).default; | ||
// console.log('Before mapping', data); | ||
const transformedData = data.map((item, index) => ({ ...item, place: index + 1 })); | ||
// console.log('After mapping', data); | ||
setPastData(transformedData); | ||
}; | ||
|
||
fetchPastLeaderboadData(); | ||
}, [round, ghostLegion]); | ||
|
||
return pastData; | ||
}; | ||
|
||
export default usePastData; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.