useGMFYRatingLeaderboard
import { useGMFYRatingLeaderboard } from 'gmfy-sdk'
Motivation
If you need to render your UI or simply process data, you can use the useGMFYRatingLeaderboard
hook. The hook allows you to get a list of leaders of a certain rating. If updateInterval
was passed to provider component config, it will return new values once every updateInterval
ms. Returns a list of leaders and the current request status
Typing
type RatingLeaderboardUnit = {
userId: string;
clientId: string;
ratingId: string;
name: string;
value: number;
metaInfo: Record<string, any>;
position: number;
}
type Status = 'initial' | | 'done' | 'fail'
useGMFYRatingLeaderboard(): { ratingLeaderboard: <Array<RatingLeaderboardUnit>> | null; status: Status }
RatingLeaderboardUnit
userId
- user IDclientId
- client IDratingId
- rating IDname
- rating namevalue
- user ratingmetaInfo
- user informationposition
- user’s position in the ranking
Status
initial
- initial status, the request has not yet been sentdone
- the request was successfulfail
- an error occurred while executing the request
Usage
import { useGMFYRatingLeaderboard } from 'gmfy-sdk';
const App = () => {
const { ratingLeaderboard, status } = useGMFYRatingLeaderboard();
if (status !== 'done') {
return <Preloader />;
}
return <YourTableComponent data={ratingLeaderboard} />;
};