diff --git a/src/context/ChannelActionContext.tsx b/src/context/ChannelActionContext.tsx index 036f2135b2..d53278b4fc 100644 --- a/src/context/ChannelActionContext.tsx +++ b/src/context/ChannelActionContext.tsx @@ -14,7 +14,7 @@ import type { import type { ChannelStateReducerAction } from '../components/Channel/channelState'; import type { CustomMentionHandler } from '../components/Message/hooks/useMentionsHandler'; -import type { ChannelUnreadUiState, UnknownType } from '../types/types'; +import type { ChannelUnreadUiState } from '../types/types'; export type MarkReadWrapperOptions = { /** @@ -97,28 +97,3 @@ export const useChannelActionContext = (componentName?: string) => { return contextValue as unknown as ChannelActionContextValue; }; - -/** - * Typescript currently does not support partial inference, so if ChannelActionContext - * typing is desired while using the HOC withChannelActionContext, the Props for the - * wrapped component must be provided as the first generic. - */ -export const withChannelActionContext =

( - Component: React.ComponentType

, -) => { - const WithChannelActionContextComponent = ( - props: Omit, - ) => { - const channelActionContext = useChannelActionContext(); - - return ; - }; - - WithChannelActionContextComponent.displayName = ( - Component.displayName || - Component.name || - 'Component' - ).replace('Base', ''); - - return WithChannelActionContextComponent; -}; diff --git a/src/context/ChannelStateContext.tsx b/src/context/ChannelStateContext.tsx index 39c5135ae9..07c27887fb 100644 --- a/src/context/ChannelStateContext.tsx +++ b/src/context/ChannelStateContext.tsx @@ -12,7 +12,6 @@ import type { import type { ChannelUnreadUiState, ImageAttachmentSizeHandler, - UnknownType, VideoAttachmentSizeHandler, } from '../types/types'; @@ -87,28 +86,3 @@ export const useChannelStateContext = (componentName?: string) => { return contextValue as unknown as ChannelStateContextValue; }; - -/** - * Typescript currently does not support partial inference, so if ChannelStateContext - * typing is desired while using the HOC withChannelStateContext, the Props for the - * wrapped component must be provided as the first generic. - */ -export const withChannelStateContext =

( - Component: React.ComponentType

, -) => { - const WithChannelStateContextComponent = ( - props: Omit, - ) => { - const channelStateContext = useChannelStateContext(); - - return ; - }; - - WithChannelStateContextComponent.displayName = ( - Component.displayName || - Component.name || - 'Component' - ).replace('Base', ''); - - return WithChannelStateContextComponent; -}; diff --git a/src/context/ChatContext.tsx b/src/context/ChatContext.tsx index 7e13db3e7f..fbd7f74c7a 100644 --- a/src/context/ChatContext.tsx +++ b/src/context/ChatContext.tsx @@ -7,9 +7,7 @@ import type { SearchController, } from 'stream-chat'; -import { getDisplayName } from './utils/getDisplayName'; import type { ChatProps } from '../components/Chat/Chat'; -import type { UnknownType } from '../types/types'; import type { ChannelsQueryState } from '../components/Chat/hooks/useChannelsQueryState'; type CSSClasses = @@ -90,20 +88,3 @@ export const useChatContext = (componentName?: string) => { return contextValue as unknown as ChatContextValue; }; - -/** - * Typescript currently does not support partial inference so if ChatContext - * typing is desired while using the HOC withChatContext the Props for the - * wrapped component must be provided as the first generic. - */ -export const withChatContext =

( - Component: React.ComponentType

, -) => { - const WithChatContextComponent = (props: Omit) => { - const chatContext = useChatContext(); - - return ; - }; - WithChatContextComponent.displayName = `WithChatContext${getDisplayName(Component)}`; - return WithChatContextComponent; -}; diff --git a/src/context/ComponentContext.tsx b/src/context/ComponentContext.tsx index ea5bd927a2..5094d6254b 100644 --- a/src/context/ComponentContext.tsx +++ b/src/context/ComponentContext.tsx @@ -67,7 +67,7 @@ import type { SearchSourceResultListProps, } from '../experimental'; -import type { PropsWithChildrenOnly, UnknownType } from '../types/types'; +import type { PropsWithChildrenOnly } from '../types/types'; import type { StopAIGenerationButtonProps } from '../components/MessageInput/StopAIGenerationButton'; import type { ShareLocationDialogProps } from '../components/Location'; import type { VideoPlayerProps } from '../components/VideoPlayer'; @@ -276,26 +276,3 @@ export const useComponentContext = ( // eslint-disable-next-line @typescript-eslint/no-unused-vars _componentName?: string, ) => useContext(ComponentContext) as unknown as ComponentContextValue; - -/** - * Typescript currently does not support partial inference, so if ComponentContext - * typing is desired while using the HOC withComponentContext, the Props for the - * wrapped component must be provided as the first generic. - */ -export const withComponentContext =

( - Component: React.ComponentType

, -) => { - const WithComponentContextComponent = (props: Omit) => { - const componentContext = useComponentContext(); - - return ; - }; - - WithComponentContextComponent.displayName = ( - Component.displayName || - Component.name || - 'Component' - ).replace('Base', ''); - - return WithComponentContextComponent; -}; diff --git a/src/context/MessageContext.tsx b/src/context/MessageContext.tsx index edd68f0793..b795e8ae38 100644 --- a/src/context/MessageContext.tsx +++ b/src/context/MessageContext.tsx @@ -24,7 +24,6 @@ import type { } from '../components/Reactions/types'; import type { RenderTextOptions } from '../components/Message/renderText'; -import type { UnknownType } from '../types/types'; export type MessageContextValue = { /** If actions such as edit, delete, flag, mute are enabled on Message */ @@ -171,26 +170,3 @@ export const useMessageContext = ( return contextValue as unknown as MessageContextValue; }; - -/** - * Typescript currently does not support partial inference, so if MessageContext - * typing is desired while using the HOC withMessageContext, the Props for the - * wrapped component must be provided as the first generic. - */ -export const withMessageContext =

( - Component: React.ComponentType

, -) => { - const WithMessageContextComponent = (props: Omit) => { - const messageContext = useMessageContext(); - - return ; - }; - - WithMessageContextComponent.displayName = ( - Component.displayName || - Component.name || - 'Component' - ).replace('Base', ''); - - return WithMessageContextComponent; -}; diff --git a/src/context/TranslationContext.tsx b/src/context/TranslationContext.tsx index f574b42f83..6d98eba379 100644 --- a/src/context/TranslationContext.tsx +++ b/src/context/TranslationContext.tsx @@ -6,9 +6,7 @@ import type { PropsWithChildren } from 'react'; import type { TFunction } from 'i18next'; import type { TranslationLanguages } from 'stream-chat'; -import { getDisplayName } from './utils/getDisplayName'; import { defaultDateTimeParser, defaultTranslatorFunction } from '../i18n/utils'; -import type { UnknownType } from '../types/types'; import type { TDateTimeParser } from '../i18n/types'; Dayjs.extend(calendar); @@ -46,21 +44,3 @@ export const useTranslationContext = (componentName?: string) => { return contextValue; }; - -export const withTranslationContext =

( - Component: React.ComponentType

, -) => { - const WithTranslationContextComponent = ( - props: Omit, - ) => { - const translationContext = useTranslationContext(); - - return ; - }; - - WithTranslationContextComponent.displayName = `WithTranslationContext${getDisplayName( - Component, - )}`; - - return WithTranslationContextComponent; -}; diff --git a/src/context/TypingContext.tsx b/src/context/TypingContext.tsx index 2cb7889f43..cb518a3eda 100644 --- a/src/context/TypingContext.tsx +++ b/src/context/TypingContext.tsx @@ -2,7 +2,6 @@ import React, { useContext } from 'react'; import type { PropsWithChildren } from 'react'; import type { ChannelState as StreamChannelState } from 'stream-chat'; -import type { UnknownType } from '../types/types'; export type TypingContextValue = { typing?: StreamChannelState['typing']; @@ -36,26 +35,3 @@ export const useTypingContext = (componentName?: string) => { return contextValue as TypingContextValue; }; - -/** - * Typescript currently does not support partial inference, so if TypingContext - * typing is desired while using the HOC withTypingContext, the Props for the - * wrapped component must be provided as the first generic. - */ -export const withTypingContext =

( - Component: React.ComponentType

, -) => { - const WithTypingContextComponent = (props: Omit) => { - const typingContext = useTypingContext(); - - return ; - }; - - WithTypingContextComponent.displayName = ( - Component.displayName || - Component.name || - 'Component' - ).replace('Base', ''); - - return WithTypingContextComponent; -}; diff --git a/src/context/utils/getDisplayName.ts b/src/context/utils/getDisplayName.ts deleted file mode 100644 index 3ca577192f..0000000000 --- a/src/context/utils/getDisplayName.ts +++ /dev/null @@ -1,5 +0,0 @@ -import type { UnknownType } from '../../types/types'; - -export const getDisplayName =

( - Component: React.ComponentType

, -) => Component.displayName || Component.name || 'Component';