import React, { FC, memo } from '../../lib/teact/teact';
import { OwnProps } from './HeaderMenuContainer';
import { Bundles } from '../../util/moduleLoader';

import useModuleLoader from '../../hooks/useModuleLoader';

const HeaderMenuContainerAsync: FC<OwnProps> = (props) => {
  const { isOpen } = props;
  const HeaderMenuContainer = useModuleLoader(Bundles.Extra, 'HeaderMenuContainer', !isOpen);

  // eslint-disable-next-line react/jsx-props-no-spreading
  return HeaderMenuContainer ? <HeaderMenuContainer {...props} /> : undefined;
};

export default memo(HeaderMenuContainerAsync);
