Skip to content

Commit 55ce02a

Browse files
authored
fix: Use ReactNode and ReactElement (#277)
* Changelog shouldn't be changed * Use ReactNode and ReactElement for custom render components
1 parent 9d8d0be commit 55ce02a

File tree

2 files changed

+67
-67
lines changed

2 files changed

+67
-67
lines changed

CHANGELOG_v2.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ channel OpenChannelSettings
294294
- Features/Bugs:
295295
* ChannelList
296296
* disableUserProfile: boolean
297-
* renderUserProfile: React.ReactElement
297+
* renderUserProfile: React.Copmonent
298298

299299
## 1.2.4(Sept 17, 2020) Deprecated
300300

@@ -304,14 +304,14 @@ channel OpenChannelSettings
304304

305305
* SendBirdProvider
306306
* disableUserProfile: boolean
307-
* renderUserProfile: React.ReactElement
307+
* renderUserProfile: React.Copmonent
308308
* allowProfileEdit: boolean
309309
* Channel
310310
* disableUserProfile: boolean
311-
* renderUserProfile: React.ReactElement
311+
* renderUserProfile: React.Copmonent
312312
* ChannelSettings
313313
* disableUserProfile: boolean
314-
* renderUserProfile: React.ReactElement
314+
* renderUserProfile: React.Copmonent
315315
* ChannelList
316316
* renderHeader(): React.ReactElement
317317
* allowProfileEdit: boolean

scripts/index_d_ts

Lines changed: 63 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ declare module "SendbirdUIKitGlobal" {
2727
allowProfileEdit?: boolean;
2828
disableUserProfile?: boolean;
2929
showSearchIcon?: boolean;
30-
renderUserProfile?: (props: RenderUserProfileProps) => React.ReactElement;
30+
renderUserProfile?: (props: RenderUserProfileProps) => React.ReactNode | React.ReactElement;
3131
onProfileEditSuccess?(user: User): void;
3232
config?: SendbirdProviderConfig;
3333
useReaction?: boolean;
@@ -182,13 +182,13 @@ declare module "SendbirdUIKitGlobal" {
182182
configureSession?: (sdk: SendbirdGroupChat | SendbirdOpenChat) => SessionHandler;
183183
customApiHost?: string,
184184
customWebSocketHost?: string,
185-
children?: React.ReactElement;
185+
children?: React.ReactNode | React.ReactElement;
186186
theme?: 'light' | 'dark';
187187
nickname?: string;
188188
profileUrl?: string;
189189
dateLocale?: Locale;
190190
disableUserProfile?: boolean;
191-
renderUserProfile?: (props: RenderUserProfileProps) => React.ReactElement;
191+
renderUserProfile?: (props: RenderUserProfileProps) => React.ReactNode | React.ReactElement;
192192
allowProfileEdit?: boolean;
193193
userListQuery?(): UserListQuery;
194194
config?: SendbirdProviderConfig;
@@ -207,7 +207,7 @@ declare module "SendbirdUIKitGlobal" {
207207

208208
export interface SendBirdStateConfig {
209209
disableUserProfile: boolean;
210-
renderUserProfile?: (props: RenderUserProfileProps) => React.ReactElement;
210+
renderUserProfile?: (props: RenderUserProfileProps) => React.ReactNode | React.ReactElement;
211211
allowProfileEdit: boolean;
212212
isOnline: boolean;
213213
isMentionEnabled: boolean;
@@ -301,9 +301,9 @@ declare module "SendbirdUIKitGlobal" {
301301
onChannelSelect?(channel: GroupChannel): void;
302302
sortChannelList?: (channels: GroupChannel[]) => GroupChannel[];
303303
queries?: ChannelListQueries;
304-
children?: React.ReactElement;
304+
children?: React.ReactNode | React.ReactElement;
305305
className?: string | Array<string>;
306-
renderUserProfile?: (props: RenderUserProfileProps) => React.ReactElement;
306+
renderUserProfile?: (props: RenderUserProfileProps) => React.ReactNode | React.ReactElement;
307307
disableUserProfile?: boolean;
308308
disableAutoSelect?: boolean;
309309
isTypingIndicatorEnabled?: boolean;
@@ -333,19 +333,19 @@ declare module "SendbirdUIKitGlobal" {
333333
}
334334

335335
export interface ChannelListUIProps {
336-
renderChannelPreview?: (props: RenderChannelPreviewProps) => React.ReactElement;
337-
renderUserProfile?: (props: RenderUserProfileProps) => React.ReactElement;
338-
renderHeader?: (props: void) => React.ReactElement;
339-
renderPlaceHolderError?: (props: void) => React.ReactElement;
340-
renderPlaceHolderLoading?: (props: void) => React.ReactElement;
341-
renderPlaceHolderEmptyList?: (props: void) => React.ReactElement;
336+
renderChannelPreview?: (props: RenderChannelPreviewProps) => React.ReactNode | React.ReactElement;
337+
renderUserProfile?: (props: RenderUserProfileProps) => React.ReactNode | React.ReactElement;
338+
renderHeader?: (props: void) => React.ReactNode | React.ReactElement;
339+
renderPlaceHolderError?: (props: void) => React.ReactNode | React.ReactElement;
340+
renderPlaceHolderLoading?: (props: void) => React.ReactNode | React.ReactElement;
341+
renderPlaceHolderEmptyList?: (props: void) => React.ReactNode | React.ReactElement;
342342
}
343343

344344
export interface ChannelListProps extends ChannelListProviderProps, ChannelListUIProps { }
345345

346346
export interface ChannelListHeaderInterface {
347-
renderHeader?: (props: void) => React.ReactElement;
348-
renderIconButton?: (props: void) => React.ReactElement;
347+
renderHeader?: (props: void) => React.ReactNode | React.ReactElement;
348+
renderIconButton?: (props: void) => React.ReactNode | React.ReactElement;
349349
onEdit?: (props: void) => void;
350350
allowProfileEdit?: boolean;
351351
}
@@ -354,7 +354,7 @@ declare module "SendbirdUIKitGlobal" {
354354
channel: GroupChannel;
355355
isActive?: boolean;
356356
onClick: () => void;
357-
renderChannelAction: (props: { channel: GroupChannel }) => React.ReactElement;
357+
renderChannelAction: (props: { channel: GroupChannel }) => React.ReactNode | React.ReactElement;
358358
tabIndex: number;
359359
}
360360

@@ -375,10 +375,10 @@ declare module "SendbirdUIKitGlobal" {
375375
}
376376

377377
export interface ChannelSettingsUIProps {
378-
renderPlaceholderError?: () => React.ReactElement;
379-
renderChannelProfile?: () => React.ReactElement;
380-
renderModerationPanel?: () => React.ReactElement;
381-
renderLeaveChannel?: () => React.ReactElement;
378+
renderPlaceholderError?: () => React.ReactNode | React.ReactElement;
379+
renderChannelProfile?: () => React.ReactNode | React.ReactElement;
380+
renderModerationPanel?: () => React.ReactNode | React.ReactElement;
381+
renderLeaveChannel?: () => React.ReactNode | React.ReactElement;
382382
}
383383

384384
export interface ApplicationUserListQuery {
@@ -400,7 +400,7 @@ declare module "SendbirdUIKitGlobal" {
400400
onChannelModified?(channel: GroupChannel): void;
401401
onBeforeUpdateChannel?(currentTitle: string, currentImg: File, data: string): GroupChannelUpdateParams;
402402
queries?: ChannelSettingsQueries;
403-
renderUserProfile?: (props: RenderUserProfileProps) => React.ReactElement;
403+
renderUserProfile?: (props: RenderUserProfileProps) => React.ReactNode | React.ReactElement;
404404
disableUserProfile?: boolean;
405405
}
406406

@@ -462,20 +462,20 @@ declare module "SendbirdUIKitGlobal" {
462462
onSearchClick?(): void;
463463
replyType?: ReplyType;
464464
queries?: ChannelQueries;
465-
renderUserProfile?: (props: RenderUserProfileProps) => React.ReactElement;
465+
renderUserProfile?: (props: RenderUserProfileProps) => React.ReactNode | React.ReactElement;
466466
disableUserProfile?: boolean;
467467
renderUserMentionItem?: (props: { user: User }) => JSX.Element;
468468
};
469469

470470
export interface ChannelUIProps {
471-
renderPlaceholderLoader?: () => React.ReactElement;
472-
renderPlaceholderInvalid?: () => React.ReactElement;
473-
renderPlaceholderEmpty?: () => React.ReactElement;
474-
renderChannelHeader?: () => React.ReactElement;
475-
renderMessage?: (props: RenderMessageProps) => React.ReactElement;
476-
renderMessageInput?: () => React.ReactElement;
477-
renderTypingIndicator?: () => React.ReactElement;
478-
renderCustomSeperator?: () => React.ReactElement;
471+
renderPlaceholderLoader?: () => React.ReactNode | React.ReactElement;
472+
renderPlaceholderInvalid?: () => React.ReactNode | React.ReactElement;
473+
renderPlaceholderEmpty?: () => React.ReactNode | React.ReactElement;
474+
renderChannelHeader?: () => React.ReactNode | React.ReactElement;
475+
renderMessage?: (props: RenderMessageProps) => React.ReactNode | React.ReactElement;
476+
renderMessageInput?: () => React.ReactNode | React.ReactElement;
477+
renderTypingIndicator?: () => React.ReactNode | React.ReactElement;
478+
renderCustomSeperator?: () => React.ReactNode | React.ReactElement;
479479
}
480480

481481
export type CoreMessageType = AdminMessage | UserMessage | FileMessage;
@@ -524,16 +524,16 @@ declare module "SendbirdUIKitGlobal" {
524524
chainBottom?: boolean;
525525
handleScroll: () => void;
526526
// for extending
527-
renderMessage?: (props: RenderMessageProps) => React.ReactElement;
528-
renderCustomSeperator?: () => React.ReactElement;
529-
renderEditInput?: () => React.ReactElement;
530-
renderMessageContent?: () => React.ReactElement;
527+
renderMessage?: (props: RenderMessageProps) => React.ReactNode | React.ReactElement;
528+
renderCustomSeperator?: () => React.ReactNode | React.ReactElement;
529+
renderEditInput?: () => React.ReactNode | React.ReactElement;
530+
renderMessageContent?: () => React.ReactNode | React.ReactElement;
531531
};
532532

533533
export type MessageListProps = {
534-
renderMessage?: (props: RenderMessageProps) => React.ReactElement;
535-
renderPlaceholderEmpty?: () => React.ReactElement;
536-
renderCustomSeperator?: () => React.ReactElement;
534+
renderMessage?: (props: RenderMessageProps) => React.ReactNode | React.ReactElement;
535+
renderPlaceholderEmpty?: () => React.ReactNode | React.ReactElement;
536+
renderCustomSeperator?: () => React.ReactNode | React.ReactElement;
537537
};
538538

539539
export type SuggestedMentionListProps = {
@@ -598,15 +598,15 @@ declare module "SendbirdUIKitGlobal" {
598598

599599
export interface OpenChannelProviderProps {
600600
channelUrl: string;
601-
children?: React.ReactElement;
601+
children?: React.ReactNode | React.ReactElement;
602602
useMessageGrouping?: boolean;
603603
queries?: OpenChannelQueries;
604604
messageLimit?: number;
605605
onBeforeSendUserMessage?(text: string): UserMessageCreateParams;
606606
onBeforeSendFileMessage?(file_: File): FileMessageCreateParams;
607607
onChatHeaderActionClick?(): void;
608608
disableUserProfile?: boolean;
609-
renderUserProfile?: (props: RenderUserProfileProps) => React.ReactElement;
609+
renderUserProfile?: (props: RenderUserProfileProps) => React.ReactNode | React.ReactElement;
610610
}
611611

612612
export interface OpenChannelMessagesState {
@@ -638,24 +638,24 @@ declare module "SendbirdUIKitGlobal" {
638638
}
639639

640640
export interface OpenChannelUIProps {
641-
renderMessage?: (props: RenderMessageProps) => React.ReactElement;
642-
renderHeader?: () => React.ReactElement;
643-
renderInput?: () => React.ReactElement;
644-
renderPlaceHolderEmptyList?: () => React.ReactElement;
645-
renderPlaceHolderError?: () => React.ReactElement;
646-
renderPlaceHolderLoading?: () => React.ReactElement;
641+
renderMessage?: (props: RenderMessageProps) => React.ReactNode | React.ReactElement;
642+
renderHeader?: () => React.ReactNode | React.ReactElement;
643+
renderInput?: () => React.ReactNode | React.ReactElement;
644+
renderPlaceHolderEmptyList?: () => React.ReactNode | React.ReactElement;
645+
renderPlaceHolderError?: () => React.ReactNode | React.ReactElement;
646+
renderPlaceHolderLoading?: () => React.ReactNode | React.ReactElement;
647647
}
648648

649649
export interface OpenChannelProps extends OpenChannelProviderProps, OpenChannelUIProps {
650650
}
651651

652652
export type OpenchannelMessageListProps = {
653-
renderMessage?: (props: RenderMessageProps) => React.ReactElement;
654-
renderPlaceHolderEmptyList?: () => React.ReactElement;
653+
renderMessage?: (props: RenderMessageProps) => React.ReactNode | React.ReactElement;
654+
renderPlaceHolderEmptyList?: () => React.ReactNode | React.ReactElement;
655655
}
656656

657657
export type OpenChannelMessageProps = {
658-
renderMessage?: (props: RenderMessageProps) => React.ReactElement;
658+
renderMessage?: (props: RenderMessageProps) => React.ReactNode | React.ReactElement;
659659
message: EveryMessage;
660660
chainTop?: boolean;
661661
chainBottom?: boolean;
@@ -674,12 +674,12 @@ declare module "SendbirdUIKitGlobal" {
674674
onChannelModified?(channel: OpenChannel): void;
675675
onDeleteChannel?(channel: OpenChannel): void;
676676
disableUserProfile?: boolean;
677-
renderUserProfile?: (props: RenderUserProfileProps) => React.ReactElement;
677+
renderUserProfile?: (props: RenderUserProfileProps) => React.ReactNode | React.ReactElement;
678678
}
679679

680680
export interface OpenChannelSettingsUIProps {
681-
renderOperatorUI?: () => React.ReactElement;
682-
renderParticipantList?: () => React.ReactElement;
681+
renderOperatorUI?: () => React.ReactNode | React.ReactElement;
682+
renderParticipantList?: () => React.ReactNode | React.ReactElement;
683683
}
684684

685685
export interface OpenChannelSettingsProps extends OpenChannelSettingsContextProps, OpenChannelSettingsUIProps {
@@ -692,7 +692,7 @@ declare module "SendbirdUIKitGlobal" {
692692
}
693693

694694
export interface OperatorUIProps {
695-
renderChannelProfile?: () => React.ReactElement;
695+
renderChannelProfile?: () => React.ReactNode | React.ReactElement;
696696
}
697697

698698
export interface OpenChannelEditDetailsProps {
@@ -704,7 +704,7 @@ declare module "SendbirdUIKitGlobal" {
704704
*/
705705
export interface MessageSearchProviderProps {
706706
channelUrl: string;
707-
children?: React.ReactElement;
707+
children?: React.ReactNode | React.ReactElement;
708708
searchString?: string;
709709
requestString?: string;
710710
messageSearchQuery?: MessageSearchQuery;
@@ -740,10 +740,10 @@ declare module "SendbirdUIKitGlobal" {
740740
}
741741

742742
export interface MessageSearchUIProps {
743-
renderPlaceHolderError?: (props: void) => React.ReactElement;
744-
renderPlaceHolderLoading?: (props: void) => React.ReactElement;
745-
renderPlaceHolderNoString?: (props: void) => React.ReactElement;
746-
renderPlaceHolderEmptyList?: (props: void) => React.ReactElement;
743+
renderPlaceHolderError?: (props: void) => React.ReactNode | React.ReactElement;
744+
renderPlaceHolderLoading?: (props: void) => React.ReactNode | React.ReactElement;
745+
renderPlaceHolderNoString?: (props: void) => React.ReactNode | React.ReactElement;
746+
renderPlaceHolderEmptyList?: (props: void) => React.ReactNode | React.ReactElement;
747747
renderSearchItem?(
748748
{
749749
message,
@@ -763,7 +763,7 @@ declare module "SendbirdUIKitGlobal" {
763763
* CreateChannel
764764
*/
765765
export interface CreateChannelProviderProps {
766-
children?: React.ReactElement;
766+
children?: React.ReactNode | React.ReactElement;
767767
onCreateChannel(channel: GroupChannel): void;
768768
onBeforeCreateChannel?(users: Array<string>): GroupChannelCreateParams;
769769
userListQuery?(): UserListQuery;
@@ -783,7 +783,7 @@ declare module "SendbirdUIKitGlobal" {
783783

784784
export interface CreateChannelUIProps {
785785
onCancel?(): void;
786-
renderStepOne?: (props: void) => React.ReactElement;
786+
renderStepOne?: (props: void) => React.ReactNode | React.ReactElement;
787787
}
788788

789789
export interface CreateChannelProps extends CreateChannelProviderProps, CreateChannelUIProps { }
@@ -800,7 +800,7 @@ declare module "SendbirdUIKitGlobal" {
800800
* EditUserProfile
801801
*/
802802
export interface EditUserProfileProps {
803-
children?: React.ReactElement;
803+
children?: React.ReactNode | React.ReactElement;
804804
onCancel?(): void;
805805
onThemeChange?(theme: string): void;
806806
onEditProfile?(updatedUser: User): void;
@@ -826,9 +826,9 @@ declare module '@sendbird/uikit-react' {
826826
export const OpenChannelSettings: React.FunctionComponent<SendbirdUIKitGlobal.OpenChannelSettingsProps>
827827
export const MessageSearch: React.FunctionComponent<SendbirdUIKitGlobal.MessageSearchProps>
828828
export function withSendBird(
829-
ChildComp: React.Component | React.ElementType | React.ReactElement,
829+
ChildComp: React.Component | React.ElementType | React.ReactNode | React.ReactElement,
830830
mapStoreToProps?: (store: SendbirdUIKitGlobal.SendBirdState) => unknown
831-
): (props: unknown) => React.ReactElement;
831+
): (props: unknown) => React.ReactNode | React.ReactElement;
832832
export function useSendbirdStateContext(): SendbirdUIKitGlobal.SendBirdState;
833833
}
834834

@@ -859,9 +859,9 @@ declare module '@sendbird/uikit-react/useSendbirdStateContext' {
859859
declare module '@sendbird/uikit-react/withSendbird' {
860860
import SendbirdUIKitGlobal from 'SendbirdUIKitGlobal';
861861
function withSendbird(
862-
ChildComp: React.Component | React.ElementType | React.ReactElement,
862+
ChildComp: React.Component | React.ElementType | React.ReactNode | React.ReactElement,
863863
mapStoreToProps?: (store: SendbirdUIKitGlobal.SendBirdState) => unknown
864-
): (props: unknown) => React.ReactElement;
864+
): (props: unknown) => React.ReactNode | React.ReactElement;
865865
export default withSendbird;
866866
}
867867

0 commit comments

Comments
 (0)