useUserMemberships for PubNub Chat Components for React Native
Migrate to Chat SDK
PubNub will stop supporting Chat Components on January 1, 2025 but you are welcome to contribute. Learn how to migrate to the Chat SDK here.
The hook returns a list of channel memberships for a user.
This method doesn't return user's subscriptions. Pagination is handled internally. You can adjust the limit of returned channels on a single call (max/default 100) and call a function returned by the hook to get another page of results.
This hook also sets up a listener that reacts to removals of already fetched channels. Updates and new memberships are not handled due to technical limitations. However, this behavior requires a living subscription to the user getting updated - this should be handled by the components.
User ID / UUID
User ID is also referred to as UUID/uuid in some APIs and server responses but holds the value of the userId parameter you set during initialization.
1const [channels, fetchPage, refetchMemberships, total, error, isLoading] = useUserMemberships({
2 uuid: "user",
3});
4
5return (
6 <Chat {...{ options }}>
7 <ChannelList channels={channels} />
8 </Chat>
9);
Input
| Parameter | Defaults | Description |
|---|---|---|
includeType: Object | n/a | Option to include respective additional fields in the response. |
→ customFieldsType: Boolean | false | Option to fetch custom fields or not. |
→ channelFieldsType: Boolean | false | Option to include fields for channels metadata. |