refactor(features/ui): Avoid useless renders in WrappedSwitch (#5580)
This commit is contained in:
		
							parent
							
								
									c858c1a2b8
								
							
						
					
					
						commit
						2c6bb251c5
					
				
					 1 changed files with 13 additions and 5 deletions
				
			
		| 
						 | 
					@ -7,11 +7,19 @@ import BundleColumnError from '../components/bundle_column_error';
 | 
				
			||||||
import BundleContainer from '../containers/bundle_container';
 | 
					import BundleContainer from '../containers/bundle_container';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Small wrapper to pass multiColumn to the route components
 | 
					// Small wrapper to pass multiColumn to the route components
 | 
				
			||||||
export const WrappedSwitch = ({ multiColumn, children }) => (
 | 
					export class WrappedSwitch extends React.PureComponent {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  render () {
 | 
				
			||||||
 | 
					    const { multiColumn, children } = this.props;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return (
 | 
				
			||||||
      <Switch>
 | 
					      <Switch>
 | 
				
			||||||
        {React.Children.map(children, child => React.cloneElement(child, { multiColumn }))}
 | 
					        {React.Children.map(children, child => React.cloneElement(child, { multiColumn }))}
 | 
				
			||||||
      </Switch>
 | 
					      </Switch>
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
WrappedSwitch.propTypes = {
 | 
					WrappedSwitch.propTypes = {
 | 
				
			||||||
  multiColumn: PropTypes.bool,
 | 
					  multiColumn: PropTypes.bool,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue