Skip to content

Commit 58c79b3

Browse files
authored
Merge pull request #160 from sendbird/fix/types
fix: use ComponentType instead of function structure in CommonComponent type
2 parents efe57e3 + 6c5beef commit 58c79b3

File tree

3 files changed

+8
-14
lines changed

3 files changed

+8
-14
lines changed

packages/uikit-react-native/src/components/ChannelInput/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919

2020
import { useSendbirdChat } from '../../hooks/useContext';
2121
import useMentionTextInput from '../../hooks/useMentionTextInput';
22-
import type { MentionedUser, Range } from '../../types';
22+
import type { CommonComponent, MentionedUser, Range } from '../../types';
2323
import type { AttachmentsButtonProps } from './AttachmentsButton';
2424
import AttachmentsButton from './AttachmentsButton';
2525
import EditInput from './EditInput';
@@ -67,7 +67,7 @@ export type ChannelInputProps = {
6767
setMessageToReply?: (message?: undefined | SendbirdUserMessage | SendbirdFileMessage) => void;
6868

6969
// mention
70-
SuggestedMentionList?: (props: SuggestedMentionListProps) => React.ReactNode | null;
70+
SuggestedMentionList?: CommonComponent<SuggestedMentionListProps>;
7171

7272
// sub-components
7373
AttachmentsButton?: (props: AttachmentsButtonProps) => React.ReactNode | null;

packages/uikit-react-native/src/components/ChannelMessageList/index.tsx

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import {
3232
import type { UserProfileContextType } from '../../contexts/UserProfileCtx';
3333
import { useLocalization, usePlatformService, useSendbirdChat, useUserProfile } from '../../hooks/useContext';
3434
import SBUUtils from '../../libs/SBUUtils';
35-
import type { CommonComponent } from '../../types';
3635
import ChatFlatList from '../ChatFlatList';
3736
import { ReactionAddons } from '../ReactionAddons';
3837

@@ -78,15 +77,10 @@ export type ChannelMessageListProps<T extends SendbirdGroupChannel | SendbirdOpe
7877
bottomSheetItem?: BottomSheetItem;
7978
isFirstItem: boolean;
8079
}) => React.ReactElement | null;
81-
renderNewMessagesButton: null | CommonComponent<{
82-
visible: boolean;
83-
onPress: () => void;
84-
newMessages: SendbirdMessage[];
85-
}>;
86-
renderScrollToBottomButton: null | CommonComponent<{
87-
visible: boolean;
88-
onPress: () => void;
89-
}>;
80+
renderNewMessagesButton:
81+
| null
82+
| ((props: { visible: boolean; onPress: () => void; newMessages: SendbirdMessage[] }) => React.ReactElement | null);
83+
renderScrollToBottomButton: null | ((props: { visible: boolean; onPress: () => void }) => React.ReactElement | null);
9084
flatListProps?: Omit<FlatListProps<SendbirdMessage>, 'data' | 'renderItem'>;
9185
} & {
9286
ref?: Ref<FlatList<SendbirdMessage>> | undefined;

packages/uikit-react-native/src/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { ErrorInfo, ReactNode } from 'react';
1+
import type { ComponentType, ErrorInfo, ReactNode } from 'react';
22

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

@@ -17,7 +17,7 @@ export interface LocalCacheStorage {
1717

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

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

2222
export type MentionedUser = {
2323
range: Range;

0 commit comments

Comments
 (0)