소스 검색

refactor(features/ui): Avoid useless renders in WrappedSwitch (#5580)

master
Sorin Davidoi 6 년 전
committed by Eugen Rochko
부모
커밋
5521e94e24
1개의 변경된 파일13개의 추가작업 그리고 5개의 파일을 삭제
  1. +13
    -5
      app/javascript/mastodon/features/ui/util/react_router_helpers.js

+ 13
- 5
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,


불러오는 중...
취소
저장