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: packages/react-router-dom/docs/api/BrowserRouter.md
+13-14
Original file line number
Diff line number
Diff line change
@@ -3,15 +3,13 @@
3
3
A [`<Router>`](../../../react-router/docs/api/Router.md) that uses the HTML5 history API (`pushState`, `replaceState` and the `popstate` event) to keep your UI in sync with the URL.
4
4
5
5
```jsx
6
-
import { BrowserRouter } from'react-router-dom'
7
-
8
6
<BrowserRouter
9
7
basename={optionalString}
10
8
forceRefresh={optionalBool}
11
9
getUserConfirmation={optionalFunc}
12
10
keyLength={optionalNumber}
13
11
>
14
-
<App/>
12
+
<App/>
15
13
</BrowserRouter>
16
14
```
17
15
@@ -29,22 +27,21 @@ The base URL for all locations. If your app is served from a sub-directory on yo
29
27
A function to use to confirm navigation. Defaults to using [`window.confirm`](https://developer.mozilla.org/en-US/docs/Web/API/Window/confirm).
If `true` the router will use full page refreshes on page navigation. You probably only want this in [browsers that don't support the HTML5 history API](http://caniuse.com/#feat=history).
41
+
If `true` the router will use full page refreshes on page navigation. You may want to use this to imitate the way a traditional server-rendered app would work with full page refreshes between page navigation.
44
42
45
43
```jsx
46
-
constsupportsHistory='pushState'inwindow.history
47
-
<BrowserRouter forceRefresh={!supportsHistory} />
44
+
<BrowserRouter forceRefresh={true} />
48
45
```
49
46
50
47
## keyLength: number
@@ -57,4 +54,6 @@ The length of `location.key`. Defaults to 6.
57
54
58
55
## children: node
59
56
60
-
A [single child element](https://facebook.github.io/react/docs/react-api.html#reactchildrenonly) to render.
57
+
The child elements to render.
58
+
59
+
Note: On React < 16 you must use a [single child element](https://facebook.github.io/react/docs/react-api.html#reactchildrenonly) since a render method cannot return more than one element. If you need more than one element, you might try wrapping them in an extra `<div>`.
Copy file name to clipboardExpand all lines: packages/react-router-dom/docs/api/HashRouter.md
+13-11
Original file line number
Diff line number
Diff line change
@@ -5,10 +5,12 @@ A [`<Router>`](../../../react-router/docs/api/Router.md) that uses the hash port
5
5
**IMPORTANT NOTE:** Hash history does not support `location.key` or `location.state`. In previous versions we attempted to shim the behavior but there were edge-cases we couldn't solve. Any code or plugin that needs this behavior won't work. As this technique is only intended to support legacy browsers, we encourage you to configure your server to work with `<BrowserHistory>` instead.
6
6
7
7
```jsx
8
-
import { HashRouter } from'react-router-dom'
9
-
10
-
<HashRouter>
11
-
<App/>
8
+
<HashRouter
9
+
basename={optionalString}
10
+
getUserConfirmation={optionalFunc}
11
+
hashType={optionalString}
12
+
>
13
+
<App />
12
14
</HashRouter>
13
15
```
14
16
@@ -26,13 +28,13 @@ The base URL for all locations. A properly formatted basename should have a lead
26
28
A function to use to confirm navigation. Defaults to using [`window.confirm`](https://developer.mozilla.org/en-US/docs/Web/API/Window/confirm).
Copy file name to clipboardExpand all lines: packages/react-router-dom/docs/api/Link.md
+14-10
Original file line number
Diff line number
Diff line change
@@ -3,8 +3,6 @@
3
3
Provides declarative, accessible navigation around your application.
4
4
5
5
```jsx
6
-
import { Link } from'react-router-dom'
7
-
8
6
<Link to="/about">About</Link>
9
7
```
10
8
@@ -58,22 +56,28 @@ When `true`, clicking the link will replace the current entry in the history sta
58
56
59
57
## innerRef: function
60
58
61
-
Allows access to the underlying `ref` of the component
59
+
As of React Router 5.1, if you are using React 16 you should not need this prop because we [forward the ref](https://reactjs.org/docs/forwarding-refs.html)to the underlying `<a>`. Use a normal `ref` instead.
62
60
63
-
```jsx
64
-
constrefCallback=node=> {
65
-
// `node` refers to the mounted DOM element or null when unmounted
66
-
}
61
+
Allows access to the underlying `ref` of the component.
67
62
68
-
<Link to="/" innerRef={refCallback} />
63
+
```jsx
64
+
<Link
65
+
to="/"
66
+
innerRef={node=> {
67
+
// `node` refers to the mounted DOM element
68
+
// or null when unmounted
69
+
}}
70
+
/>
69
71
```
70
72
71
73
## innerRef: RefObject
72
74
73
-
Get the underlying `ref` of the component with `React.createRef()`
75
+
As of React Router 5.1, if you are using React 16 you should not need this prop because we [forward the ref](https://reactjs.org/docs/forwarding-refs.html) to the underlying `<a>`. Use a normal `ref` instead.
76
+
77
+
Get the underlying `ref` of the component using [`React.createRef`](https://reactjs.org/docs/refs-and-the-dom.html#creating-refs).
Copy file name to clipboardExpand all lines: packages/react-router-dom/docs/api/NavLink.md
+12-13
Original file line number
Diff line number
Diff line change
@@ -3,8 +3,6 @@
3
3
A special version of the [`<Link>`](Link.md) that will add styling attributes to the rendered element when it matches the current URL.
4
4
5
5
```jsx
6
-
import { NavLink } from'react-router-dom'
7
-
8
6
<NavLink to="/about">About</NavLink>
9
7
```
10
8
@@ -59,19 +57,20 @@ When `true`, the trailing slash on a location's `pathname` will be taken into co
59
57
A function to add extra logic for determining whether the link is active. This should be used if you want to do more than verify that the link's pathname matches the current URL's `pathname`.
60
58
61
59
```jsx
62
-
// only consider an event active if its event id is an odd number
63
-
constoddEvent= (match, location) => {
64
-
if (!match) {
65
-
returnfalse
66
-
}
67
-
consteventID=parseInt(match.params.eventID)
68
-
return!isNaN(eventID) && eventID %2===1
69
-
}
70
-
71
60
<NavLink
72
61
to="/events/123"
73
-
isActive={oddEvent}
74
-
>Event123</NavLink>
62
+
isActive={(match, location) => {
63
+
if (!match) {
64
+
returnfalse;
65
+
}
66
+
67
+
// only consider an event active if its event id is an odd number
Copy file name to clipboardExpand all lines: packages/react-router-dom/docs/guides/code-splitting.md
+6-6
Original file line number
Diff line number
Diff line change
@@ -14,12 +14,12 @@ One great feature of the web is that we don't have to make our visitors download
14
14
[`loadable-components`] is a library for loading components with dynamic imports. It handles all sorts of edge cases automatically and makes code splitting simple! Here's an example of how to use [`loadable-components`]:
0 commit comments