6.2.0 • Published 7 years ago
react-wildcat-ensure v6.2.0
react-wildcat-ensure
A wrapper for System.import
that behaves like Webpack's require.ensure
:
- initial import calls are asynchronous
- subsequent import calls returns a synchronous cached import response
Designed for compatibility with React Router's asynchronous route loading.
Installation
jspm:
jspm install react-wildcat-ensure
npm:
npm install react-wildcat-ensure
Usage
Importing a single module:
import ensure from "react-wildcat-ensure";
// Lazy loaded component
export function getComponent(location, cb) {
ensure("./AsyncComponent.js", module, (err, module) => {
return cb(err, module);
});
}
Importing a key/value hash of modules:
import ensure from "react-wildcat-ensure";
// Lazy loaded index route
export function getIndexRoute(location, cb) {
ensure({
header: "./AsyncHeader.js",
component: "./AsyncComponent.js"
}, module, (err, modules) => {
return cb(err, modules);
});
}
Importing an array of modules:
import ensure from "react-wildcat-ensure";
// Lazy loaded child routes
export function getChildRoutes(location, cb) {
ensure([
"./AsyncChildRouteOne.js",
"./AsyncChildRouteTwo.js"
], module, (err, modules) => {
return cb(err, modules);
});
}
License
MIT
6.2.0
7 years ago
6.0.0
7 years ago
5.0.0
8 years ago
4.1.0
8 years ago
4.0.0
8 years ago
3.0.0
8 years ago
2.4.4
8 years ago
2.0.0
8 years ago
1.0.0
8 years ago
1.0.0-rc8
8 years ago
1.0.0-rc7
8 years ago
1.0.0-rc6
8 years ago
1.0.0-rc5
8 years ago
1.0.0-rc4
8 years ago
1.0.0-rc3
8 years ago
1.0.0-rc2
8 years ago
1.0.0-rc1
8 years ago
1.0.0-beta10
8 years ago
1.0.0-beta9
8 years ago
1.0.0-beta8
8 years ago
1.0.0-beta7
8 years ago
1.0.0-beta6
8 years ago
1.0.0-beta5
8 years ago
1.0.0-beta4
8 years ago
1.0.0-beta3
8 years ago