Search code examples
javascriptreactjsmarkdown

ReactMarkdown without wrapping div


I'm using ReactMarkdown component (https://github.com/rexxars/react-markdown).

It works correct. Except that all output is wrapped with a div.

After research i found the solution:


Solution

  • My Solution:

    ReactMarkdown accepts a prop "renderers". You can pass an object with keys for every node type. And when you set the key "root" to React.Fragment it renders all flat. Without the wrapping div:

    <ReactMarkdown source={myMdString} renderers={{ root: React.Fragment }} />