You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/API.md
+19-5Lines changed: 19 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@
4
4
-[`<Router>`](#router)
5
5
-[`<Link>`](#link)
6
6
-[`<IndexLink>`](#indexlink)
7
-
-[`withRouter`](#withroutercomponent)
7
+
-[`withRouter`](#withroutercomponent-options)
8
8
-[`<RouterContext>`](#routercontext)
9
9
-[`context.router`](#contextrouter)
10
10
-`<RoutingContext>` (deprecated, use `<RouterContext>`)
@@ -157,8 +157,22 @@ Given a route like `<Route path="/users/:userId" />`:
157
157
### `<IndexLink>`
158
158
An `<IndexLink>` is like a [`<Link>`](#link), except it is only active when the current route is exactly the linked route. It is equivalent to `<Link>` with the `onlyActiveOnIndex` prop set.
159
159
160
-
### `withRouter(component)`
161
-
A HoC (higher-order component) that wraps another component to provide `this.props.router`. Pass in your component and it will return the wrapped component.
160
+
### `withRouter(Component, [options])`
161
+
A HoC (higher-order component) that wraps another component to provide `props.router`. Pass in your component and it will return the wrapped component.
162
+
163
+
You can explicit specify `router` as a prop to the wrapper component to override the router object from context.
164
+
165
+
#### Options
166
+
167
+
##### `withRef`
168
+
If `true`, the wrapper component attaches a ref to the wrapped component, which can then be accessed via `getWrappedInstance`.
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.
@@ -621,7 +635,7 @@ For more details, please see the [histories guide](/docs/guides/Histories.md).
621
635
`hashHistory` uses URL hashes, along with a query key to keep track of state. `hashHistory` requires no additional server configuration, but is generally less preferred than `browserHistory`.
622
636
623
637
624
-
### `createMemoryHistory(options)`
638
+
### `createMemoryHistory([options])`
625
639
`createMemoryHistory` creates an in-memory `history` object that does not interact with the browser URL. This is useful for when you need to customize the `history` object used for server-side rendering, for automated testing, or for when you do not want to manipulate the browser URL, such as when your application is embedded in an `<iframe>`.
This function is to be used for server-side rendering. It matches a set of routes to a location, without rendering, and calls a `callback(error, redirectLocation, renderProps)` when it's done.
0 commit comments