@towns-protocol/react-sdk
Version:
React Hooks for Towns Protocol SDK
18 lines • 800 B
JavaScript
'use client';
import { useMemo } from 'react';
import { useSyncAgent } from './useSyncAgent';
import { useObservable } from './useObservable';
/**
* Hook to get data about a channel.
* You can use this hook to get channel metadata and if the user has joined the channel.
* @param spaceId - The id of the space the channel belongs to.
* @param channelId - The id of the channel to get data about.
* @param config - Configuration options for the observable.
* @returns The ChannelModel data.
*/
export const useChannel = (spaceId, channelId, config) => {
const sync = useSyncAgent();
const channel = useMemo(() => sync.spaces.getSpace(spaceId).getChannel(channelId), [sync.spaces, spaceId, channelId]);
return useObservable(channel, config);
};
//# sourceMappingURL=useChannel.js.map