react-router
Version:
A complete routing library for React
101 lines (79 loc) • 4.11 kB
JavaScript
'use strict';
exports.__esModule = true;
exports.router = exports.routes = exports.route = exports.components = exports.component = exports.location = exports.history = exports.falsy = exports.locationShape = exports.routerShape = undefined;
var _react = require('react');
var _deprecateObjectProperties = require('./deprecateObjectProperties');
var _deprecateObjectProperties2 = _interopRequireDefault(_deprecateObjectProperties);
var _InternalPropTypes = require('./InternalPropTypes');
var InternalPropTypes = _interopRequireWildcard(_InternalPropTypes);
var _routerWarning = require('./routerWarning');
var _routerWarning2 = _interopRequireDefault(_routerWarning);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var func = _react.PropTypes.func;
var object = _react.PropTypes.object;
var shape = _react.PropTypes.shape;
var string = _react.PropTypes.string;
var routerShape = exports.routerShape = shape({
push: func.isRequired,
replace: func.isRequired,
go: func.isRequired,
goBack: func.isRequired,
goForward: func.isRequired,
setRouteLeaveHook: func.isRequired,
isActive: func.isRequired
});
var locationShape = exports.locationShape = shape({
pathname: string.isRequired,
search: string.isRequired,
state: object,
action: string.isRequired,
key: string
});
// Deprecated stuff below:
var falsy = exports.falsy = InternalPropTypes.falsy;
var history = exports.history = InternalPropTypes.history;
var location = exports.location = locationShape;
var component = exports.component = InternalPropTypes.component;
var components = exports.components = InternalPropTypes.components;
var route = exports.route = InternalPropTypes.route;
var routes = exports.routes = InternalPropTypes.routes;
var router = exports.router = routerShape;
if (process.env.NODE_ENV !== 'production') {
(function () {
var deprecatePropType = function deprecatePropType(propType, message) {
return function () {
process.env.NODE_ENV !== 'production' ? (0, _routerWarning2.default)(false, message) : void 0;
return propType.apply(undefined, arguments);
};
};
var deprecateInternalPropType = function deprecateInternalPropType(propType) {
return deprecatePropType(propType, 'This prop type is not intended for external use, and was previously exported by mistake. These internal prop types are deprecated for external use, and will be removed in a later version.');
};
var deprecateRenamedPropType = function deprecateRenamedPropType(propType, name) {
return deprecatePropType(propType, 'The `' + name + '` prop type is now exported as `' + name + 'Shape` to avoid name conflicts. This export is deprecated and will be removed in a later version.');
};
exports.falsy = falsy = deprecateInternalPropType(falsy);
exports.history = history = deprecateInternalPropType(history);
exports.component = component = deprecateInternalPropType(component);
exports.components = components = deprecateInternalPropType(components);
exports.route = route = deprecateInternalPropType(route);
exports.routes = routes = deprecateInternalPropType(routes);
exports.location = location = deprecateRenamedPropType(location, 'location');
exports.router = router = deprecateRenamedPropType(router, 'router');
})();
}
var defaultExport = {
falsy: falsy,
history: history,
location: location,
component: component,
components: components,
route: route,
// For some reason, routes was never here.
router: router
};
if (process.env.NODE_ENV !== 'production') {
defaultExport = (0, _deprecateObjectProperties2.default)(defaultExport, 'The default export from `react-router/lib/PropTypes` is deprecated. Please use the named exports instead.');
}
exports.default = defaultExport;