Skip to content

Fix: Bubble component typing regression#2639

Merged
kesha-antonov merged 1 commit into
FaridSafi:masterfrom
habovh:fix/bubble-type-param
Jul 16, 2025
Merged

Fix: Bubble component typing regression#2639
kesha-antonov merged 1 commit into
FaridSafi:masterfrom
habovh:fix/bubble-type-param

Conversation

@habovh
Copy link
Copy Markdown
Contributor

@habovh habovh commented Jul 16, 2025

PR #2609 introduced a type regression by migrating the Bubble component from a class component to a function component using React.FC, which does not support generics.

This commit replaces React.FC with generics and a JSX.Element return type on the Bubble component, allowing to keep the function component and bringing back the type argument. The type argument here is necessary to provide accurate type information for non-vanilla messages.

Since generics are used quite extensively on this project especially around message object customization, I recommend to steer away from using React.FC for consistency's sake.

For those wanting to use a ready-to-go patch using patch-package for example, here you go:

react-native-gifted-chat+2.8.1.patch
diff --git a/node_modules/react-native-gifted-chat/lib/Bubble/index.d.ts b/node_modules/react-native-gifted-chat/lib/Bubble/index.d.ts
index 5a9d350..51a36b2 100644
--- a/node_modules/react-native-gifted-chat/lib/Bubble/index.d.ts
+++ b/node_modules/react-native-gifted-chat/lib/Bubble/index.d.ts
@@ -1,6 +1,6 @@
-import React from 'react';
+import { JSX } from 'react';
 import { IMessage } from '../types';
 import { BubbleProps } from './types';
 export * from './types';
-declare const Bubble: React.FC<BubbleProps<IMessage>>;
+declare const Bubble: <TMessage extends IMessage = IMessage>(props: BubbleProps<TMessage>) => JSX.Element;
 export default Bubble;

@kesha-antonov feel free to review and provide feedback, I might have missed some things or reasons why you decided to went with React.FC in the first place here.

PR FaridSafi#2609 introduced a regression in the types by migrating the Bubble
component from a class component to using React.FC, which does not support generics.

This commit replaces React.FC with generics and a JSX.Element return type on the
Bubble component, allowing to keep the function component and bringing back the
type argument.
@kesha-antonov kesha-antonov merged commit 40858cf into FaridSafi:master Jul 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants