useChannelMembers for PubNub Chat Components for React Native
USED BY THE OLD IA, PLEASE DISREGARD
The hook returns a list of members in a channel.
The list includes user metadata for members that have additional metadata stored in the database. Pagination is handled internally. You can adjust the limit of returned members 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 members. Updates and new memberships are not handled due to technical limitations. However, this behavior requires a living subscription to the channel getting updated - this should be handled by the components.
1const [members, fetchPage, refetchChannelMembers, total, error, isLoading] = useChannelMembers({
2 channel: "channel",
3});
4
5return (
6 <Chat {...{ options }}>
7 <MemberList members={members} />
8 </Chat>
9);
Input
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.
include#- Option to include respective additional fields in the response.
- Defaults
- n/a
- →
UUIDFields# - Option to include fields for User ID metadata.
- Defaults
false
- →
customUUIDFields# - Option to include custom fields for User ID metadata.
- Defaults
false
filter#- Expression used to filter the results. Only objects whose properties satisfy the given expression are returned. See the App Context Filtering Language Definition for more details.
- Defaults
- n/a
sort#- Key-value pair of a property to sort by and a sort direction.
Available options areid,name, andupdated.
Useascordescto specify sort direction, or specifynullto take the default sort direction (ascending).
Example:{name: 'asc'}- Defaults
- n/a
limit#- Number of objects to return in response.
Default is100which is also the maximum value.- Defaults
100
Output
array[0]#- List of returned members.
array[1]#- Function that can be called to fetch another page of members.
array[2]#- Function that can be called to completely reset the hook. This can be used in case of expected members updates.
array[3]#- Total number of stored members.
array[4]#- If there's an error fetching members, it will be available here.
array[5]#- Indicator that the channel member data is still being loaded.