about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSorin Davidoi <sorin.davidoi@gmail.com>2017-11-01 12:17:53 +0100
committerEugen Rochko <eugen@zeonfederated.com>2017-11-01 12:17:53 +0100
commit5521e94e24bc0ce4258d612ea074334b2af85e54 (patch)
tree740d43343ff967718c0693f6ac83850d373805aa
parent763a2f8511dcdb14b4a665bba2c6e2880b6d6b68 (diff)
refactor(features/ui): Avoid useless renders in WrappedSwitch (#5580)
-rw-r--r--app/javascript/mastodon/features/ui/util/react_router_helpers.js18
1 files changed, 13 insertions, 5 deletions
diff --git a/app/javascript/mastodon/features/ui/util/react_router_helpers.js b/app/javascript/mastodon/features/ui/util/react_router_helpers.js
index 86b30d488..43007ddc3 100644
--- a/app/javascript/mastodon/features/ui/util/react_router_helpers.js
+++ b/app/javascript/mastodon/features/ui/util/react_router_helpers.js
@@ -7,11 +7,19 @@ import BundleColumnError from '../components/bundle_column_error';
 import BundleContainer from '../containers/bundle_container';
 
 // Small wrapper to pass multiColumn to the route components
-export const WrappedSwitch = ({ multiColumn, children }) => (
-  <Switch>
-    {React.Children.map(children, child => React.cloneElement(child, { multiColumn }))}
-  </Switch>
-);
+export class WrappedSwitch extends React.PureComponent {
+
+  render () {
+    const { multiColumn, children } = this.props;
+
+    return (
+      <Switch>
+        {React.Children.map(children, child => React.cloneElement(child, { multiColumn }))}
+      </Switch>
+    );
+  }
+
+}
 
 WrappedSwitch.propTypes = {
   multiColumn: PropTypes.bool,