How to import a markdown file and display it


when I write the markdown as a string,it works fine.But I prefer to import the markdown file and render it,like:

When I tried this way, I was prompted to need a loader.

so I add a markdown-loader in the webpack.config.js,but I failed. I don’t know exactly what loader does rendering a markdown need and how to edit the webpack.config.js rightly.If anyone has tried to render a markdown in a .tsx file,please tell me how you did that,thanks^-^

@Darya Since a markdown file is nothing but a string/text, you can probably get away with using a general asset type rule, see here.

Thanks for your reply,but the markdown file I actually need is huge,so a md loader is necessary in my case,do you know any way to resole a imported .md file sucessfully.

I don’t see how the size of the markdown file has anything to do with what kind of loader you need. In the end, all you want is for the require('.../help.md') call to return a string containing its content, right? That’s what the linked documentation should help you accomplish.