Skip to content

Commit 684f960

Browse files
author
tfomkin
committed
fix: props fix, a key prop is being spread into JSX error fix
1 parent 0fd57ee commit 684f960

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

libs/mobile/shared/features/markdown-view/src/lib/component.tsx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import markdownItMath from 'markdown-it-math/no-default-renderer';
33
import { colorScheme } from 'nativewind';
44
import React, { PropsWithChildren, ReactElement, ReactNode, useCallback, useMemo } from 'react';
55
import { Linking } from 'react-native';
6+
import FitImage from 'react-native-fit-image';
67
import Markdown, { ASTNode, MarkdownProps, RenderRules } from 'react-native-markdown-display';
78
import { CitationPrefix } from '@open-webui-react-native/mobile/chat/features/use-citations';
89
import { CodeBlock } from '@open-webui-react-native/mobile/shared/ui/code-block';
@@ -39,6 +40,7 @@ export function AppMarkdownView({
3940
onCitationPress,
4041
isContentReady,
4142
textColor: elementTextColor,
43+
children,
4244
}: AppMarkdownViewProps): ReactElement {
4345
const { isDarkColorScheme } = useColorScheme();
4446
const textColor = elementTextColor || (isDarkColorScheme ? colors.darkTextPrimary : colors.textPrimary);
@@ -208,6 +210,18 @@ export function AppMarkdownView({
208210
</AppText>
209211
),
210212
table: renderTable,
213+
//NOTE: A props object containing a "key" prop is being spread into JSX error fix
214+
image: (node: ASTNode, children, parent, styles) => {
215+
const uri = node.attributes?.src;
216+
217+
if (!uri) return null;
218+
219+
return <FitImage
220+
key={`image-${node.key}`}
221+
source={{ uri }}
222+
style={styles.image}
223+
resizeMode='contain' />;
224+
},
211225
};
212226
}, [fence, onCitationPress, isContentReady, renderTable]);
213227

@@ -219,8 +233,9 @@ export function AppMarkdownView({
219233
code_inline: { backgroundColor: isDarkColorScheme ? colors.gray700 : colors.gray75 },
220234
}}
221235
rules={markdownRules}
222-
markdownit={markdownItInstance}
223-
/>
236+
markdownit={markdownItInstance}>
237+
{children}
238+
</Markdown>
224239
);
225240
}
226241

0 commit comments

Comments
 (0)