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: FAQ.md
-5
Original file line number
Diff line number
Diff line change
@@ -4,16 +4,11 @@ This is a list of support questions that frequently show up in GitHub issues. Th
4
4
5
5
If there is a support question that you frequently see being asked, please open a PR to add it to this list.
6
6
7
-
-[Why aren't my components updating when the location changes?](#why-arent-my-components-updating-when-the-location-changes)
8
7
-[Why doesn't my application render after refreshing?](#why-doesnt-my-application-render-after-refreshing)
9
8
-[Why doesn't my application work when loading nested routes?](#why-doesnt-my-application-work-when-loading-nested-routes)
10
9
-[How do I access the `history` object outside of components?](#how-do-i-access-the-history-object-outside-of-components)
11
10
-[How do I pass props to the component rendered by a `<Route>`?](#how-do-i-pass-props-to-the-component-rendered-by-a-route)
12
11
13
-
### Why aren't my components updating when the location changes?
14
-
15
-
React Router relies on updates propagating from your router component to every child component. If you (or a component you use) implements `shouldComponentUpdate` or is a `React.PureComponent`, you may run into issues where your components do not update when the location changes. For a detailed review of the problem, please see the [blocked updates guide](packages/react-router/docs/guides/blocked-updates.md).
16
-
17
12
### Why doesn't my application render after refreshing?
18
13
19
14
If your application is hosted on a static file server, you need to use a `<HashRouter>` instead of a `<BrowserRouter>`.
`withRouter` does not subscribe to location changes like React Redux's `connect` does for state changes. Instead, re-renders after location changes propagate out from the `<Router>` component. This means that `withRouter` does _not_ re-render on route transitions unless its parent component re-renders. If you are using `withRouter` to prevent updates from being blocked by `shouldComponentUpdate`, it is important that `withRouter` wraps the component that implements `shouldComponentUpdate`. For example, when using Redux:
33
-
34
-
```js
35
-
// This gets around shouldComponentUpdate
36
-
withRouter(connect(...)(MyComponent))
37
-
// or
38
-
compose(
39
-
withRouter,
40
-
connect(...)
41
-
)(MyComponent)
42
-
43
-
// This does not
44
-
connect(...)(withRouter(MyComponent))
45
-
// nor
46
-
compose(
47
-
connect(...),
48
-
withRouter
49
-
)(MyComponent)
50
-
```
51
-
52
-
See [this guide](https://github.com/ReactTraining/react-router/blob/master/packages/react-router/docs/guides/blocked-updates.md) for more information.
32
+
`withRouter` does not subscribe to location changes like React Redux's `connect` does for state changes. Instead, re-renders after location changes propagate out from the `<Router>` component. This means that `withRouter` does _not_ re-render on route transitions unless its parent component re-renders.
0 commit comments