Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: replace JSX.Element with ReactNode type #2645

Merged
merged 2 commits into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@
"@emoji-mart/data": "^1.1.0",
"@emoji-mart/react": "^1.1.0",
"emoji-mart": "^5.4.0",
"react": "^19.0.0 || ^18.0.0 || ^17.0.0 || ^16.8.0",
"react-dom": "^19.0.0 || ^18.0.0 || ^17.0.0 || ^16.8.0",
"react": "^19.0.0 || ^18.0.0 || ^17.0.0 || ^16.14.0",
"react-dom": "^19.0.0 || ^18.0.0 || ^17.0.0 || ^16.14.0",
"stream-chat": "^8.55.0"
},
"peerDependenciesMeta": {
Expand Down
4 changes: 2 additions & 2 deletions src/components/ChannelList/ChannelList.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useCallback, useEffect, useRef, useState } from 'react';
import React, { ReactNode, useCallback, useEffect, useRef, useState } from 'react';
import clsx from 'clsx';

import { ChannelListMessenger, ChannelListMessengerProps } from './ChannelListMessenger';
Expand Down Expand Up @@ -97,7 +97,7 @@ export type ChannelListProps<
t: TranslationContextValue['t'],
userLanguage: TranslationContextValue['userLanguage'],
isMessageAIGenerated?: ChatContextValue['isMessageAIGenerated'],
) => string | JSX.Element;
) => ReactNode;
/** Custom UI component to display the container for the queried channels, defaults to and accepts same props as: [ChannelListMessenger](https://github.com/GetStream/stream-chat-react/blob/master/src/components/ChannelList/ChannelListMessenger.tsx) */
List?: React.ComponentType<ChannelListMessengerProps<StreamChatGenerics>>;
/** Custom UI component to display the loading error indicator, defaults to component that renders null */
Expand Down
8 changes: 4 additions & 4 deletions src/components/ChannelPreview/ChannelPreview.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import throttle from 'lodash.throttle';
import React, { useEffect, useMemo, useState } from 'react';
import React, { ReactNode, useEffect, useMemo, useState } from 'react';

import { ChannelPreviewMessenger } from './ChannelPreviewMessenger';
import { useIsChannelMuted } from './hooks/useIsChannelMuted';
Expand Down Expand Up @@ -33,9 +33,9 @@ export type ChannelPreviewUIComponentProps<
/** The last message received in a channel */
lastMessage?: StreamMessage<StreamChatGenerics>;
/** @deprecated Use latestMessagePreview prop instead. */
latestMessage?: string | JSX.Element;
latestMessage?: ReactNode;
/** Latest message preview to display, will be a string or JSX element supporting markdown. */
latestMessagePreview?: string | JSX.Element;
latestMessagePreview?: ReactNode;
/** Status describing whether own message has been delivered or read by another. If the last message is not an own message, then the status is undefined. */
messageDeliveryStatus?: MessageDeliveryStatus;
/** Number of unread Messages */
Expand All @@ -62,7 +62,7 @@ export type ChannelPreviewProps<
channel: Channel<StreamChatGenerics>,
t: TranslationContextValue['t'],
userLanguage: TranslationContextValue['userLanguage'],
) => string | JSX.Element;
) => ReactNode;
key?: string;
/** Custom ChannelPreview click handler function */
onSelect?: (event: React.MouseEvent) => void;
Expand Down
12 changes: 6 additions & 6 deletions src/components/ChannelPreview/utils.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { ReactNode } from 'react';

import ReactMarkdown from 'react-markdown';

Expand Down Expand Up @@ -37,7 +37,7 @@
t: TranslationContextValue['t'],
userLanguage: TranslationContextValue['userLanguage'] = 'en',
isMessageAIGenerated?: ChatContextValue<StreamChatGenerics>['isMessageAIGenerated'],
): string | JSX.Element => {
): ReactNode => {
const latestMessage =
channel.state.latestMessages[channel.state.latestMessages.length - 1];

Expand All @@ -47,11 +47,11 @@
const poll = latestMessage?.poll;

if (!latestMessage) {
return t('Nothing yet...');
return t<string>('Nothing yet...');
}

if (latestMessage.deleted_at) {
return t('Message deleted');
return t<string>('Message deleted');
}

if (poll) {
Expand Down Expand Up @@ -94,10 +94,10 @@
}

if (latestMessage.attachments?.length) {
return t('🏙 Attachment...');
return t<string>('🏙 Attachment...');
}

return t('Empty message...');
return t<string>('Empty message...');

Check warning on line 100 in src/components/ChannelPreview/utils.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/ChannelPreview/utils.tsx#L100

Added line #L100 was not covered by tests
};

export type GroupChannelDisplayInfo = { image?: string; name?: string }[];
Expand Down
3 changes: 2 additions & 1 deletion src/components/Message/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { TFunction } from 'i18next';
import type { ReactNode } from 'react';
import type { ReactionSort, UserResponse } from 'stream-chat';

import type { PinPermissions, UserEventHandler } from './hooks';
Expand Down Expand Up @@ -109,7 +110,7 @@ export type MessageProps<
text?: string,
mentioned_users?: UserResponse<StreamChatGenerics>[],
options?: RenderTextOptions,
) => JSX.Element | null;
) => ReactNode;
/** Custom retry send message handler to override default in [ChannelActionContext](https://getstream.io/chat/docs/sdk/react/contexts/channel_action_context/) */
retrySendMessage?: ChannelActionContextValue<StreamChatGenerics>['retrySendMessage'];
/** Comparator function to sort the list of reacted users
Expand Down
4 changes: 2 additions & 2 deletions src/context/MessageContext.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { PropsWithChildren, useContext } from 'react';
import React, { PropsWithChildren, ReactNode, useContext } from 'react';

import type { Mute, ReactionResponse, ReactionSort, UserResponse } from 'stream-chat';

Expand Down Expand Up @@ -130,7 +130,7 @@ export type MessageContextValue<
text?: string,
mentioned_users?: UserResponse<StreamChatGenerics>[],
options?: RenderTextOptions,
) => JSX.Element | null;
) => ReactNode;
/** Comparator function to sort the list of reacted users
* @deprecated use `reactionDetailsSort` instead
*/
Expand Down
Loading