-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f3a90cc
commit 71eb480
Showing
6 changed files
with
17 additions
and
37 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -1,26 +1,11 @@ | ||
import { useEffect, useState } from 'react'; | ||
import { useQueryClient } from 'src/contexts/queryClient'; | ||
import useQueryClientMethod from 'src/hooks/useQueryClientMethod'; | ||
|
||
function useRank(cid: string) { | ||
const [rank, setRank] = useState<number>(); | ||
const { data } = useQueryClientMethod('rank', [cid]); | ||
|
||
const queryClient = useQueryClient(); | ||
const rank = data?.rank; | ||
|
||
useEffect(() => { | ||
(async () => { | ||
if (!queryClient) { | ||
return; | ||
} | ||
|
||
return; | ||
|
||
const response = await queryClient.rank(cid); | ||
|
||
setRank(Number(response.rank)); | ||
})(); | ||
}, [cid, queryClient]); | ||
|
||
return rank; | ||
return rank ? Number(rank) : undefined; | ||
} | ||
|
||
export default useRank; |
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
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