useFetchUserFollowingCount
Overview
The useFetchUserFollowingCount
hook is used to retrieve the number of users a specific user is following within the current project. This is useful for displaying the number of connections or subscriptions a user has made.
Usage Example
import { useFetchUserFollowingCount } from "@replyke/react-js";
function FollowingCountDisplay({ userId }: { userId: string }) {
const fetchUserFollowingCount = useFetchUserFollowingCount();
const handleFetchFollowingCount = async () => {
try {
const { count } = await fetchUserFollowingCount(userId);
console.log(`User is following ${count} users.`);
} catch (error) {
console.error("Failed to fetch following count:", error.message);
}
};
return <button onClick={handleFetchFollowingCount}>Get Following 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 following count for. |
Returns
The function resolves with an object containing the following count:
Return Value | Type | Description |
---|---|---|
count | { count: number } | An object containing the number of users the specified user is following. |