Skip to content

A webpack loader that renders React components to HTML strings.

License

Notifications You must be signed in to change notification settings

jas-chen/react-render-loader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

npm version

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
import React from 'react';

function Hello(props) {
  return <h1>Hello {props.name}</h1>;
}

const App = <Hello name="React" />;

export default App;



// index.js

// Use ReactDOMServer.renderToString
import AppHtml from 'react-render!./App.js';

// Use ReactDOMServer.renderToStaticMarkup
// import AppHtml from 'react-render?static=true!./App.js';

document.getElementById('root').innerHTML = AppHtml;

This loader supports

  • React class
  • React element
  • Stateless functional components
  • Array of above
  • Array of above (sub arrays)

See basic example for demo.

About

A webpack loader that renders React components to HTML strings.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages