Browse Source

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. `
main
zhangs 7 years ago
committed by Sophie Alpert
parent
commit
ef2547a4cb
  1. 6
      docs/higher-order-components.md

6
docs/higher-order-components.md

@ -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)
```

Loading…
Cancel
Save