Yuki Takei 3 лет назад
Родитель
Сommit
cd75abefb3
1 измененных файлов с 7 добавлено и 22 удалено
  1. 7 22
      packages/app/src/components/CustomNavigation/CustomTabContent.tsx

+ 7 - 22
packages/app/src/components/CustomNavigation/CustomTabContent.tsx

@@ -1,41 +1,35 @@
-import React, { useEffect, useState } from 'react';
+import React from 'react';
 
 
-import PropTypes from 'prop-types';
 import {
 import {
   TabContent, TabPane,
   TabContent, TabPane,
 } from 'reactstrap';
 } from 'reactstrap';
 
 
-import { ICustomNavTabMappings } from '~/interfaces/ui';
+import type { ICustomNavTabMappings } from '~/interfaces/ui';
+
+import { LazyRenderer } from '../Common/LazyRenderer';
 
 
 
 
 type Props = {
 type Props = {
   activeTab: string,
   activeTab: string,
   navTabMapping: ICustomNavTabMappings,
   navTabMapping: ICustomNavTabMappings,
   additionalClassNames?: string[],
   additionalClassNames?: string[],
-
 }
 }
 
 
 const CustomTabContent = (props: Props): JSX.Element => {
 const CustomTabContent = (props: Props): JSX.Element => {
 
 
   const { activeTab, navTabMapping, additionalClassNames } = props;
   const { activeTab, navTabMapping, additionalClassNames } = props;
 
 
-  const [activatedContent, setActivatedContent] = useState(new Set([activeTab]));
-
-  // add activated content to Set
-  useEffect(() => {
-    setActivatedContent(activatedContent.add(activeTab));
-  }, [activatedContent, activeTab]);
-
   return (
   return (
     <TabContent activeTab={activeTab} className={additionalClassNames != null ? additionalClassNames.join(' ') : ''}>
     <TabContent activeTab={activeTab} className={additionalClassNames != null ? additionalClassNames.join(' ') : ''}>
       {Object.entries(navTabMapping).map(([key, value]) => {
       {Object.entries(navTabMapping).map(([key, value]) => {
 
 
-        const shouldRender = key === activeTab || activatedContent.has(key);
         const { Content } = value;
         const { Content } = value;
 
 
         return (
         return (
           <TabPane key={key} tabId={key}>
           <TabPane key={key} tabId={key}>
-            { shouldRender && <Content /> }
+            <LazyRenderer shouldRender={key === activeTab}>
+              <Content />
+            </LazyRenderer>
           </TabPane>
           </TabPane>
         );
         );
       })}
       })}
@@ -44,13 +38,4 @@ const CustomTabContent = (props: Props): JSX.Element => {
 
 
 };
 };
 
 
-CustomTabContent.propTypes = {
-  activeTab: PropTypes.string.isRequired,
-  navTabMapping: PropTypes.object.isRequired,
-  additionalClassNames: PropTypes.arrayOf(PropTypes.string),
-};
-CustomTabContent.defaultProps = {
-  additionalClassNames: [],
-};
-
 export default CustomTabContent;
 export default CustomTabContent;