-
-
Notifications
You must be signed in to change notification settings - Fork 27.1k
Closed
Labels

Description
I want to load content of a HTML file as string and use dangerouslySetInnerHTML to put it in a div of React component.
For example:
<!-- staticPages/pattern.html -->
<div>
<div>
...
<div>
</div>
// pattern.jsx
import React from 'react';
import html from 'statisPages/pattern.html'
export default function Pattern() {
return (
<div dangerouslySetInnerHtml={{ __html: html }}>
</div>
);
}
I know I can export all HTML as string from a js file, but to do so I have to put HTML inside string literal and it's doesn't look pretty, I want to put it in a normal *.html file so others know it's a HTML.
Webpack has html-loader that can do this, I tested and it worked but it required to eject.
Does anybody have idea to do this, or to use html-loader without ejecting ?
Thank you.
yuki-93, memark, bceppi, 6pm, adamerose and 6 more