Skip to content

Commit bd436ce

Browse files
committed
Merge branch 'website'
2 parents a38ef04 + 97f0eee commit bd436ce

File tree

17 files changed

+195
-661
lines changed

17 files changed

+195
-661
lines changed

FAQ.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,11 @@ This is a list of support questions that frequently show up in GitHub issues. Th
44

55
If there is a support question that you frequently see being asked, please open a PR to add it to this list.
66

7-
- [Why aren't my components updating when the location changes?](#why-arent-my-components-updating-when-the-location-changes)
87
- [Why doesn't my application render after refreshing?](#why-doesnt-my-application-render-after-refreshing)
98
- [Why doesn't my application work when loading nested routes?](#why-doesnt-my-application-work-when-loading-nested-routes)
109
- [How do I access the `history` object outside of components?](#how-do-i-access-the-history-object-outside-of-components)
1110
- [How do I pass props to the component rendered by a `<Route>`?](#how-do-i-pass-props-to-the-component-rendered-by-a-route)
1211

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-
1712
### Why doesn't my application render after refreshing?
1813

1914
If your application is hosted on a static file server, you need to use a `<HashRouter>` instead of a `<BrowserRouter>`.

packages/react-router/docs/api/withRouter.md

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -29,27 +29,7 @@ const ShowTheLocationWithRouter = withRouter(ShowTheLocation);
2929

3030
#### Important Note
3131

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. 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.
5333

5434
#### Static Methods and Properties
5535

packages/react-router/docs/guides/blocked-updates.md

Lines changed: 0 additions & 200 deletions
This file was deleted.

website/modules/base.css

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,3 +258,40 @@ h3 {
258258
opacity: 1;
259259
transition: opacity 250ms ease-in;
260260
}
261+
262+
/* Just some temporary CSS for our hooks tour ad */
263+
264+
.hooks-tour {
265+
padding: 1.5em;
266+
background-image: url(https://reacttraining.com/images/blue-fade.svg),
267+
url(https://reacttraining.com/images/blue-fade.svg);
268+
background-position: 50% 0, 0 -20%;
269+
background-size: 100%;
270+
background-repeat: no-repeat;
271+
background-color: #edf4f7;
272+
border: 1px solid #d3dbde;
273+
text-align: center;
274+
border-radius: 0.5em;
275+
}
276+
277+
.hooks-tour .logo {
278+
width: 60%;
279+
}
280+
281+
.hooks-tour a {
282+
display: inline-block;
283+
margin: 0.2em 0;
284+
padding: 0.2em 0.5em;
285+
background-color: #e94948;
286+
color: #fff;
287+
border-radius: 0.2em;
288+
}
289+
290+
.hooks-tour hr {
291+
border: none;
292+
border-bottom: 1px solid #d3dbde;
293+
}
294+
295+
.hooks-tour p:last-of-type {
296+
font-size: 0.7em;
297+
}
Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,18 @@
1-
import React, { Component } from "react";
1+
import { useState, useEffect } from "react";
22

3-
class Bundle extends Component {
4-
state = {
5-
mod: null
6-
};
3+
function Bundle({ children, load }) {
4+
const [mod, setMod] = useState();
75

8-
componentWillMount() {
9-
this.load(this.props);
10-
}
6+
useEffect(
7+
() => {
8+
load(mod => {
9+
setMod(mod.default ? mod.default : mod);
10+
});
11+
},
12+
[load]
13+
);
1114

12-
componentWillReceiveProps(nextProps) {
13-
if (nextProps.load !== this.props.load) {
14-
this.load(nextProps);
15-
}
16-
}
17-
18-
load(props) {
19-
this.setState({
20-
mod: null
21-
});
22-
props.load(mod => {
23-
this.setState({ mod: mod.default ? mod.default : mod });
24-
});
25-
}
26-
27-
render() {
28-
return this.props.children(this.state.mod);
29-
}
15+
return children(mod);
3016
}
3117

3218
export default Bundle;

0 commit comments

Comments
 (0)