You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
639 B
29 lines
639 B
import { Box } from '@mui/material'; |
|
import { ReactElement, ReactNode, useMemo } from 'react'; |
|
|
|
const TabContent = <T,>({ |
|
changingTabId, |
|
children, |
|
retain = false, |
|
tabId, |
|
}: TabContentProps<T>): ReactElement => { |
|
const isTabIdMatch = useMemo( |
|
() => changingTabId === tabId, |
|
[changingTabId, tabId], |
|
); |
|
const result = useMemo<ReactNode>( |
|
() => |
|
retain ? ( |
|
<Box sx={{ display: isTabIdMatch ? 'initial' : 'none' }}> |
|
{children} |
|
</Box> |
|
) : ( |
|
isTabIdMatch && children |
|
), |
|
[children, isTabIdMatch, retain], |
|
); |
|
|
|
return <>{result}</>; |
|
}; |
|
|
|
export default TabContent;
|
|
|