[react-markdown] getting error Type '(instance: HTMLElement | null) => void' is not assignable to type '(instance: SyntaxHighlighter | null) => void' #817
-
I am getting error - Type '(instance: HTMLElement | null) => void' is not assignable to type '(instance: SyntaxHighlighter | null) => void', when I try to use code as below. Anyone knows what's happening? thanks! import { CodeComponent } from "react-markdown/src/ast-to-react";
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
@vinuthakaranth could you share a runnable example of what you are seeing? It's possible you have a different highlighter that has TypeScript typings already instead of |
Beta Was this translation helpful? Give feedback.
-
My previous renderer was something like below:
Now I tried to convert to something like below after seeing issue #815 :
but now I get below error while passing components |
Beta Was this translation helpful? Give feedback.
@vinuthakaranth could you share a runnable example of what you are seeing?
It looks like this is based off https://github.com/remarkjs/react-markdown#use-custom-components-syntax-highlight
and trying that out in a code sandbox with TypeScript, it appears to work https://codesandbox.io/s/determined-ellis-9iqvb
It's possible you have a different highlighter that has TypeScript typings already instead of
react-syntax-highlighter
.If so, it may be related to #815 and the
{...props}
spread not being compatible with the properties of the<SyntaxHighlighter>
component.