lazy-component-loader
v0.2.2
Published
lazy react component loader module for webpack
Downloads
4
Readme
Usage
// When you require a component, you get a thin wrapper.
// The real component, and all its module dependencies, are not loaded yet.
var BigComponent = require(lazy-component!./BigComponent);
function renderPage() {
// When the wrapper is mounted, the real component is loaded asynchronously.
// All props and children are passed through to the real component.
React.render(<BigComponent title="Wow!" />, document.body.firstChild);
}
You can pass a placeholder element to be rendered while the real component is still loading:
const spinner = <div className="spinner">Loading...</div>;
React.render(
<BigComponent placeholder={spinner} title="Wow!" />,
document.body.firstChild
);
License
MIT (http://www.opensource.org/licenses/mit-license.php)