Skip to main content

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 ID
  • clientId - client ID
  • ratingId - rating ID
  • name - rating name
  • value - user rating
  • metaInfo - user information
  • position - user’s position in the ranking

Status

  • initial - initial status, the request has not yet been sent
  • done - the request was successful
  • fail - 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} />;
};