react-crossroads
Version:
Client side router for web applications built with React and utilizing the Flux architecture. The backing routing engine is CrossroadsJs.
58 lines (43 loc) • 1.66 kB
JavaScript
var NotFoundRoute, React, RouteDefinition, TYPE, factory, join, merge,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
React = require('react');
RouteDefinition = require('./RouteDefinition');
merge = require('react/lib/merge');
join = require('path').join;
TYPE = 'NotFoundRoute';
NotFoundRoute = (function(_super) {
__extends(NotFoundRoute, _super);
NotFoundRoute.prototype.type = TYPE;
function NotFoundRoute(props) {
var defaultProps, path, propsPathIsString;
path = ':path*:';
defaultProps = {
handlerProps: {},
path: path
};
propsPathIsString = (props != null) && (props.path != null) && typeof props.path === 'string';
if (propsPathIsString) {
path = join(props.path, path);
}
this.props = merge(defaultProps, props);
if (propsPathIsString) {
this.props.path = path;
}
NotFoundRoute.__super__.constructor.call(this);
}
NotFoundRoute.prototype.propTypes = {
handler: RouteDefinition.PropTypes.componentClass.isRequired,
path: React.PropTypes.string.isRequired,
handlerProps: React.PropTypes.object.isRequired
};
return NotFoundRoute;
})(RouteDefinition);
factory = function(props) {
if (arguments.length > 1) {
throw new Error('NotFoundRoute does not support children');
}
return new NotFoundRoute(props);
};
factory.type = TYPE;
module.exports = factory;