stream-chat-react
Version:
React components to create chat conversations or livestream style chat
15 lines (14 loc) • 774 B
JavaScript
import React, { createContext, useContext } from 'react';
export const ChannelListContext = createContext(undefined);
/**
* Context provider for components rendered within the `ChannelList`
*/
export const ChannelListContextProvider = ({ children, value, }) => (React.createElement(ChannelListContext.Provider, { value: value }, children));
export const useChannelListContext = (componentName) => {
const contextValue = useContext(ChannelListContext);
if (!contextValue) {
console.warn(`The useChannelListContext hook was called outside of the ChannelListContext provider. Make sure this hook is called within the ChannelList component. The errored call is located in the ${componentName} component.`);
return {};
}
return contextValue;
};