mirror of
https://github.com/zebrajr/react.git
synced 2026-01-15 12:15:22 +00:00
the order of withRouter and connect is reset (#10658)
per [this link](https://github.com/ReactTraining/react-router/blob/master/packages/react-router/docs/api/withRouter.md) becasue ` If you are using withRouter to prevent updates from being blocked by shouldComponentUpdate, it is important that withRouter wraps the component that implements shouldComponentUpdate. `
This commit is contained in:
@@ -279,14 +279,14 @@ This form may seem confusing or unnecessary, but it has a useful property. Singl
|
||||
|
||||
```js
|
||||
// Instead of doing this...
|
||||
const EnhancedComponent = connect(commentSelector)(withRouter(WrappedComponent))
|
||||
const EnhancedComponent = withRouter(connect(commentSelector)(WrappedComponent))
|
||||
|
||||
// ... you can use a function composition utility
|
||||
// compose(f, g, h) is the same as (...args) => f(g(h(...args)))
|
||||
const enhance = compose(
|
||||
// These are both single-argument HOCs
|
||||
connect(commentSelector),
|
||||
withRouter
|
||||
withRouter,
|
||||
connect(commentSelector)
|
||||
)
|
||||
const EnhancedComponent = enhance(WrappedComponent)
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user