Skip to content

Commit

Permalink
Merge pull request #160 from sendbird/fix/types
Browse files Browse the repository at this point in the history
fix: use ComponentType instead of function structure in CommonComponent type
  • Loading branch information
bang9 authored Feb 2, 2024
2 parents efe57e3 + 6c5beef commit 58c79b3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {

import { useSendbirdChat } from '../../hooks/useContext';
import useMentionTextInput from '../../hooks/useMentionTextInput';
import type { MentionedUser, Range } from '../../types';
import type { CommonComponent, MentionedUser, Range } from '../../types';
import type { AttachmentsButtonProps } from './AttachmentsButton';
import AttachmentsButton from './AttachmentsButton';
import EditInput from './EditInput';
Expand Down Expand Up @@ -67,7 +67,7 @@ export type ChannelInputProps = {
setMessageToReply?: (message?: undefined | SendbirdUserMessage | SendbirdFileMessage) => void;

// mention
SuggestedMentionList?: (props: SuggestedMentionListProps) => React.ReactNode | null;
SuggestedMentionList?: CommonComponent<SuggestedMentionListProps>;

// sub-components
AttachmentsButton?: (props: AttachmentsButtonProps) => React.ReactNode | null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import {
import type { UserProfileContextType } from '../../contexts/UserProfileCtx';
import { useLocalization, usePlatformService, useSendbirdChat, useUserProfile } from '../../hooks/useContext';
import SBUUtils from '../../libs/SBUUtils';
import type { CommonComponent } from '../../types';
import ChatFlatList from '../ChatFlatList';
import { ReactionAddons } from '../ReactionAddons';

Expand Down Expand Up @@ -78,15 +77,10 @@ export type ChannelMessageListProps<T extends SendbirdGroupChannel | SendbirdOpe
bottomSheetItem?: BottomSheetItem;
isFirstItem: boolean;
}) => React.ReactElement | null;
renderNewMessagesButton: null | CommonComponent<{
visible: boolean;
onPress: () => void;
newMessages: SendbirdMessage[];
}>;
renderScrollToBottomButton: null | CommonComponent<{
visible: boolean;
onPress: () => void;
}>;
renderNewMessagesButton:
| null
| ((props: { visible: boolean; onPress: () => void; newMessages: SendbirdMessage[] }) => React.ReactElement | null);
renderScrollToBottomButton: null | ((props: { visible: boolean; onPress: () => void }) => React.ReactElement | null);
flatListProps?: Omit<FlatListProps<SendbirdMessage>, 'data' | 'renderItem'>;
} & {
ref?: Ref<FlatList<SendbirdMessage>> | undefined;
Expand Down
4 changes: 2 additions & 2 deletions packages/uikit-react-native/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ErrorInfo, ReactNode } from 'react';
import type { ComponentType, ErrorInfo, ReactNode } from 'react';

import type { SendbirdUser } from '@sendbird/uikit-utils';

Expand All @@ -17,7 +17,7 @@ export interface LocalCacheStorage {

export type ErrorBoundaryProps = { error: Error; errorInfo: ErrorInfo; reset: () => void };

export type CommonComponent<P = {}> = (props: P & { children?: ReactNode }) => null | ReactNode;
export type CommonComponent<P = {}> = ComponentType<P & { children?: ReactNode | undefined }>;

export type MentionedUser = {
range: Range;
Expand Down

0 comments on commit 58c79b3

Please sign in to comment.