react-router
Advanced tools
Comparing version 3.0.6-pre.0 to 3.1.0-rc.1
@@ -1,2 +0,2 @@ | ||
# API Reference | ||
# React Router 3 API Reference | ||
@@ -162,4 +162,16 @@ - [Components](#components) | ||
### `withRouter(Component, [options])` | ||
A HoC (higher-order component) that wraps another component to provide `props.router`. Pass in your component and it will return the wrapped component. | ||
A HoC (higher-order component) that wraps another component to enhance its props with router props. | ||
``` | ||
withRouterProps = { | ||
...componentProps, | ||
router, | ||
params, | ||
location, | ||
routes | ||
} | ||
``` | ||
Pass in your component and it will return the wrapped component. | ||
You can explicit specify `router` as a prop to the wrapper component to override the router object from context. | ||
@@ -180,3 +192,3 @@ | ||
### `<RouterContext>` | ||
A `<RouterContext>` renders the component tree for a given router state. Its used by `<Router>` but also useful for server rendering and integrating in brownfield development. | ||
A `<RouterContext>` renders the component tree for a given router state. It's used by `<Router>` but also useful for server rendering and integrating in brownfield development. | ||
@@ -183,0 +195,0 @@ It also provides a `router` object on [context](https://facebook.github.io/react/docs/context.html). |
@@ -43,3 +43,3 @@ # Glossary | ||
```js | ||
type Component = ReactClass | string; | ||
type Component = ReactClass<any> | string; | ||
``` | ||
@@ -52,3 +52,4 @@ | ||
```js | ||
type EnterHook = (nextState: RouterState, replace: RedirectFunction, callback?: Function) => any; | ||
type EnterHook = ((nextState: RouterState, replace: RedirectFunction) => any) | ||
| ((nextState: RouterState, replace: RedirectFunction, callback: (error?: ?Error) => any) => any); | ||
``` | ||
@@ -94,3 +95,3 @@ | ||
New locations are typically created each time the URL changes. You can read more about locations in [the `history` docs](https://github.com/mjackson/history/blob/v2.x/docs/Location.md). | ||
New locations are typically created each time the URL changes. You can read more about locations in [the `history` docs](https://github.com/ReactTraining/history/blob/v3/docs/Location.md). | ||
@@ -101,5 +102,5 @@ ### LocationDescriptor | ||
pathname: Pathname; | ||
search: Search; | ||
query: Query; | ||
state: LocationState; | ||
search?: Search; | ||
query?: Query; | ||
state?: LocationState; | ||
}; | ||
@@ -111,3 +112,3 @@ | ||
You can read more about location descriptors in [the `history` docs](https://github.com/mjackson/history/blob/v2.x/docs/Location.md). | ||
You can read more about location descriptors in [the `history` docs](https://github.com/ReactTraining/history/blob/v3/docs/Location.md). | ||
@@ -178,3 +179,3 @@ ## LocationKey | ||
```js | ||
type RedirectFunction = (state: ?LocationState, pathname: Pathname | Path, query: ?Query) => void; | ||
type RedirectFunction = (location: LocationDescriptor) => void; | ||
``` | ||
@@ -188,6 +189,6 @@ | ||
type Route = { | ||
component: RouteComponent; | ||
path: ?RoutePattern; | ||
onEnter: ?EnterHook; | ||
onLeave: ?LeaveHook; | ||
component?: RouteComponent; | ||
path?: RoutePattern; | ||
onEnter?: EnterHook; | ||
onLeave?: LeaveHook; | ||
}; | ||
@@ -194,0 +195,0 @@ ``` |
@@ -49,2 +49,2 @@ # Dynamic Routing | ||
Run the [huge apps](https://github.com/ReactTraining/react-router/tree/master/examples/huge-apps) example with your web inspector open and watch code get loaded in as you navigate around the demo. | ||
Run the [huge apps](https://github.com/ReactTraining/react-router/tree/v3/examples/huge-apps) example with your web inspector open and watch code get loaded in as you navigate around the demo. |
@@ -171,3 +171,3 @@ # Route Configuration | ||
[Route](/docs/Glossary.md#route)s may also define [`onEnter`](/docs/Glossary.md#enterhook) and [`onLeave`](/docs/Glossary.md#leavehook) hooks that are invoked once a transition has been [confirmed](/docs/guides/ConfirmingNavigation.md). These hooks are useful for various things like [requiring auth](https://github.com/ReactTraining/react-router/tree/master/examples/auth-flow) when a route is entered and saving stuff to persistent storage before a route unmounts. | ||
[Route](/docs/Glossary.md#route)s may also define [`onEnter`](/docs/Glossary.md#enterhook) and [`onLeave`](/docs/Glossary.md#leavehook) hooks that are invoked once a transition has been [confirmed](/docs/guides/ConfirmingNavigation.md). These hooks are useful for various things like [requiring auth](https://github.com/ReactTraining/react-router/tree/v3/examples/auth-flow) when a route is entered and saving stuff to persistent storage before a route unmounts. | ||
@@ -174,0 +174,0 @@ During a transition, [`onLeave` hooks](/docs/Glossary.md#leavehook) run first on all routes we are leaving, starting with the leaf route on up to the first common ancestor route. Next, [`onEnter` hooks](/docs/Glossary.md#enterhook) run starting with the first parent route we're entering down to the leaf route. |
@@ -76,3 +76,4 @@ React Router Testing With Jest | ||
import React, { Component, PropTypes } from 'react' | ||
import React, { Component } from 'react' | ||
import PropTypes from 'prop-types' | ||
import { Button } from 'react-bootstrap' | ||
@@ -79,0 +80,0 @@ import { Link } from 'react-router' |
@@ -0,1 +1,3 @@ | ||
# React Router 3 Documentation | ||
## Table of Contents | ||
@@ -22,3 +24,3 @@ | ||
* [Troubleshooting](Troubleshooting.md) | ||
* [API](API.md) | ||
* [React Router 3 API](API.md) | ||
* [Glossary](Glossary.md) |
@@ -47,6 +47,6 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
mixins: [ContextSubscriber('$router')], | ||
mixins: [ContextSubscriber('router')], | ||
contextTypes: { | ||
$router: routerShape | ||
router: routerShape | ||
}, | ||
@@ -74,3 +74,3 @@ | ||
var router = this.context.$router; | ||
var router = this.context.router; | ||
@@ -100,3 +100,3 @@ !router ? process.env.NODE_ENV !== 'production' ? invariant(false, '<Link>s rendered outside of a router context cannot navigate.') : invariant(false) : void 0; | ||
var router = this.context.$router; | ||
var router = this.context.router; | ||
@@ -103,0 +103,0 @@ |
@@ -21,3 +21,3 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
mixins: [ContextProvider('$router')], | ||
mixins: [ContextProvider('router')], | ||
@@ -41,3 +41,3 @@ propTypes: { | ||
childContextTypes: { | ||
$router: object.isRequired | ||
router: object.isRequired | ||
}, | ||
@@ -47,3 +47,3 @@ | ||
return { | ||
$router: this.props.router | ||
router: this.props.router | ||
}; | ||
@@ -50,0 +50,0 @@ }, |
@@ -20,5 +20,5 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
mixins: [ContextSubscriber('$router')], | ||
mixins: [ContextSubscriber('router')], | ||
contextTypes: { $router: routerShape }, | ||
contextTypes: { router: routerShape }, | ||
propTypes: { router: routerShape }, | ||
@@ -34,3 +34,3 @@ | ||
var router = this.props.router || this.context.$router; | ||
var router = this.props.router || this.context.router; | ||
if (!router) { | ||
@@ -37,0 +37,0 @@ return React.createElement(WrappedComponent, this.props); |
@@ -64,6 +64,6 @@ 'use strict'; | ||
mixins: [(0, _ContextUtils.ContextSubscriber)('$router')], | ||
mixins: [(0, _ContextUtils.ContextSubscriber)('router')], | ||
contextTypes: { | ||
$router: _PropTypes.routerShape | ||
router: _PropTypes.routerShape | ||
}, | ||
@@ -91,3 +91,3 @@ | ||
var router = this.context.$router; | ||
var router = this.context.router; | ||
@@ -117,3 +117,3 @@ !router ? process.env.NODE_ENV !== 'production' ? (0, _invariant2.default)(false, '<Link>s rendered outside of a router context cannot navigate.') : (0, _invariant2.default)(false) : void 0; | ||
var router = this.context.$router; | ||
var router = this.context.router; | ||
@@ -120,0 +120,0 @@ |
@@ -40,3 +40,3 @@ 'use strict'; | ||
mixins: [(0, _ContextUtils.ContextProvider)('$router')], | ||
mixins: [(0, _ContextUtils.ContextProvider)('router')], | ||
@@ -60,3 +60,3 @@ propTypes: { | ||
childContextTypes: { | ||
$router: _propTypes.object.isRequired | ||
router: _propTypes.object.isRequired | ||
}, | ||
@@ -66,3 +66,3 @@ | ||
return { | ||
$router: this.props.router | ||
router: this.props.router | ||
}; | ||
@@ -69,0 +69,0 @@ }, |
@@ -41,5 +41,5 @@ 'use strict'; | ||
mixins: [(0, _ContextUtils.ContextSubscriber)('$router')], | ||
mixins: [(0, _ContextUtils.ContextSubscriber)('router')], | ||
contextTypes: { $router: _PropTypes.routerShape }, | ||
contextTypes: { router: _PropTypes.routerShape }, | ||
propTypes: { router: _PropTypes.routerShape }, | ||
@@ -55,3 +55,3 @@ | ||
var router = this.props.router || this.context.$router; | ||
var router = this.props.router || this.context.router; | ||
if (!router) { | ||
@@ -58,0 +58,0 @@ return _react2.default.createElement(WrappedComponent, this.props); |
{ | ||
"name": "react-router", | ||
"version": "3.0.6-pre.0", | ||
"version": "3.1.0-rc.1", | ||
"description": "A complete routing library for React", | ||
@@ -45,3 +45,3 @@ "files": [ | ||
"peerDependencies": { | ||
"react": "^0.14.0 || ^15.0.0" | ||
"react": "^0.14.0 || ^15.0.0 || ^16.0.0-rc" | ||
}, | ||
@@ -83,5 +83,5 @@ "devDependencies": { | ||
"qs": "^6.2.1", | ||
"react": "^15.5.3", | ||
"react-dom": "^15.5.3", | ||
"react-transition-group": "^1.1.1", | ||
"react": "16", | ||
"react-addons-css-transition-group": "^15.6.0", | ||
"react-dom": "16", | ||
"rimraf": "^2.5.4", | ||
@@ -88,0 +88,0 @@ "style-loader": "^0.16.1", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
552851
93
9442
2