From ef2547a4cb69ce8470dac0f6320c2cd8e4aad361 Mon Sep 17 00:00:00 2001 From: zhangs Date: Sun, 10 Sep 2017 14:56:22 -0500 Subject: [PATCH] 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. ` --- docs/higher-order-components.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/higher-order-components.md b/docs/higher-order-components.md index 60eb5fab..b5386dd8 100644 --- a/docs/higher-order-components.md +++ b/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) ```