How to use Renderers in latest react-markdown version? #1240
-
I wanted to show a TOC from my markdown headers But I can't use the code there since it seems like the markdown react component's API has changed, and I can't pass in a custom So what is the way that we are supposed to do this now? Copied code from the link for reference
Is the new |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Welcome @himat! To answer your implied question of: "how can I support a table of contents?" To answer your direct question "How to use Renderers in latest react-markdown version?" |
Beta Was this translation helpful? Give feedback.
Welcome @himat!
Sorry you ran into a spot of trouble.
To answer your implied question of: "how can I support a table of contents?"
Use plugins instead of components: https://github.com/remarkjs/remark-toc with https://github.com/rehypejs/rehype-slug or https://github.com/rehypejs/rehype-autolink-headings
Using
components
orrenderers
will make your problem more complex than it needs to be.To answer your direct question "How to use Renderers in latest react-markdown version?"
You migrate, this is explained at length in the changelog https://github.com/remarkjs/react-markdown/blob/main/changelog.md#change-renderers-to-components