From 5521e94e24bc0ce4258d612ea074334b2af85e54 Mon Sep 17 00:00:00 2001 From: Sorin Davidoi Date: Wed, 1 Nov 2017 12:17:53 +0100 Subject: [PATCH] refactor(features/ui): Avoid useless renders in WrappedSwitch (#5580) --- .../features/ui/util/react_router_helpers.js | 18 +++++++++++++----- 1 file 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 86b30d4887..43007ddc3d 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 }) => ( - - {React.Children.map(children, child => React.cloneElement(child, { multiColumn }))} - -); +export class WrappedSwitch extends React.PureComponent { + + render () { + const { multiColumn, children } = this.props; + + return ( + + {React.Children.map(children, child => React.cloneElement(child, { multiColumn }))} + + ); + } + +} WrappedSwitch.propTypes = { multiColumn: PropTypes.bool,