React render loader for webpack
A webpack loader that renders React components to HTML strings.
Warning: This loader executes your module in a Node context, use browser api will cause errors.
Usage
// App.js; { return <h1>Hello propsname</h1>;} const App = <Hello name="React" />; ; // index.js // Use ReactDOMServer.renderToString; // Use ReactDOMServer.renderToStaticMarkup// import AppHtml from 'react-render?static=true!./App.js'; documentinnerHTML = AppHtml;
This loader supports
- React class
- React element
- Stateless functional components
- Array of above
- Array of above (sub arrays)
See basic example for demo.