CustomTabContent.tsx 1009 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import React from 'react';
  2. import {
  3. TabContent, TabPane,
  4. } from 'reactstrap';
  5. import type { ICustomNavTabMappings } from '~/interfaces/ui';
  6. import { LazyRenderer } from '../Common/LazyRenderer';
  7. type Props = {
  8. navTabMapping: ICustomNavTabMappings,
  9. activeTab?: string,
  10. additionalClassNames?: string[],
  11. }
  12. const CustomTabContent = (props: Props): JSX.Element => {
  13. const { activeTab, navTabMapping, additionalClassNames } = props;
  14. return (
  15. <TabContent activeTab={activeTab} className={additionalClassNames != null ? additionalClassNames.join(' ') : ''}>
  16. {Object.entries(navTabMapping).map(([key, value]) => {
  17. const { Content } = value;
  18. const content = Content != null ? <Content /> : <></>;
  19. return (
  20. <TabPane key={key} tabId={key}>
  21. <LazyRenderer shouldRender={key === activeTab}>
  22. {content}
  23. </LazyRenderer>
  24. </TabPane>
  25. );
  26. })}
  27. </TabContent>
  28. );
  29. };
  30. export default CustomTabContent;