Skip to content

Commit

Permalink
fix: react warning about unsupported prop (#1266)
Browse files Browse the repository at this point in the history
fixes #1265
  • Loading branch information
Yonom authored Dec 23, 2024
1 parent 3214b18 commit ee77267
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/poor-eyes-jump.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@assistant-ui/react-markdown": patch
---

fix: react warning about unsupported prop
25 changes: 17 additions & 8 deletions packages/react-markdown/src/overrides/CodeOverride.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,20 +76,29 @@ export type CodeOverrideProps = ComponentPropsWithoutRef<CodeComponent> & {
CodeHeader: ComponentType<CodeHeaderProps>;
SyntaxHighlighter: ComponentType<SyntaxHighlighterProps>;
};
componentsByLanguage?: Record<
string,
{
CodeHeader?: ComponentType<CodeHeaderProps>;
SyntaxHighlighter?: ComponentType<SyntaxHighlighterProps>;
}
>;
componentsByLanguage?:
| Record<
string,
{
CodeHeader?: ComponentType<CodeHeaderProps>;
SyntaxHighlighter?: ComponentType<SyntaxHighlighterProps>;
}
>
| undefined;
};

export const CodeOverride: FC<CodeOverrideProps> = ({
components,
componentsByLanguage,
...props
}) => {
const preProps = useContext(PreContext);
if (!preProps) return <components.Code {...props} />;
return <CodeBlockOverride components={components} {...props} />;
return (
<CodeBlockOverride
components={components}
componentsByLanguage={componentsByLanguage}
{...props}
/>
);
};

0 comments on commit ee77267

Please sign in to comment.