react-junctions
Version:
Junction-based routing for React.
30 lines • 1.13 kB
JavaScript
import * as React from 'react';
export var 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;
};
export function JunctionActiveChild(_a) {
var junction = _a.junction, env = _a.env, _b = _a.render, render = _b === void 0 ? 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;
}
}
//# sourceMappingURL=JunctionActiveChild.js.map