useFetchUserFollowersCount
Overview
The useFetchUserFollowersCount
hook is used to retrieve the number of followers for a specific user within the current project. This is useful for displaying follower counts in user profiles or social features.
Usage Example
import { useFetchUserFollowersCount } from "@replyke/react-js";
function FollowerCountDisplay({ userId }: { userId: string }) {
const fetchUserFollowersCount = useFetchUserFollowersCount();
const handleFetchFollowersCount = async () => {
try {
const { count } = await fetchUserFollowersCount(userId);
console.log(`User has ${count} followers.`);
} catch (error) {
console.error("Failed to fetch followers count:", error.message);
}
};
return <button onClick={handleFetchFollowersCount}>Get Followers Count</button>;
}
Parameters & Returns
Parameters
The hook returns a function that accepts the following parameter:
Parameter | Type | Required | Description |
---|---|---|---|
userId | string | Yes | The ID of the user to fetch follower count for. |
Returns
The function resolves with an object containing the follower count:
Return Value | Type | Description |
---|---|---|
count | { count: number } | An object containing the number of followers. |