react-junctions
Version:
Junction-based routing for React.
33 lines • 1.26 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var React = require("react");
exports.defaultJunctionActiveChildRenderer = function (_a) {
var Component = _a.Component, child = _a.child, env = _a.env;
return React.createElement(Component, (_b = {},
_b[child.type] = child,
_b.env = env,
_b));
var _b;
};
function JunctionActiveChild(_a) {
var junction = _a.junction, env = _a.env, _b = _a.render, render = _b === void 0 ? exports.defaultJunctionActiveChildRenderer : _b, _c = _a.notFoundElement, notFoundElement = _c === void 0 ? null : _c, _d = _a.busyElement, busyElement = _d === void 0 ? null : _d, _e = _a.errorElement, errorElement = _e === void 0 ? null : _e;
var child = junction.activeChild;
if (child && child.type !== "redirect") {
return render({
Component: child.component,
child: child,
env: env,
});
}
else if (junction.status === "busy") {
return busyElement;
}
else if (junction.status === "notfound") {
return notFoundElement;
}
else {
return errorElement;
}
}
exports.JunctionActiveChild = JunctionActiveChild;
//# sourceMappingURL=JunctionActiveChild.js.map