File size: 1,345 Bytes
0573fbf
 
 
 
9571865
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0573fbf
 
 
9571865
0573fbf
 
 
 
9571865
0573fbf
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import React from 'react';
import { Box } from '@mui/material';
import { tabPanelStyles } from '../theme';

export default function TabPanel({ children, value, index, keepMounted = false, ...other }) {
    const isActive = value === index;
    // keepMounted: render children unconditionally and toggle visibility via CSS,
    // so component state, audio nodes, and decoded buffers survive tab switches.
    // Use sparingly — by default we still mount/unmount so inactive tabs cost
    // nothing at idle.
    if (keepMounted) {
        return (
            <div
                role="tabpanel"
                hidden={!isActive}
                id={`simple-tabpanel-${index}`}
                aria-labelledby={`simple-tab-${index}`}
                {...other}
            >
                <Box sx={{ ...tabPanelStyles.root, display: isActive ? undefined : 'none' }}>
                    {children}
                </Box>
            </div>
        );
    }

    return (
        <div
            role="tabpanel"
            hidden={!isActive}
            id={`simple-tabpanel-${index}`}
            aria-labelledby={`simple-tab-${index}`}
            {...other}
        >
            {isActive && (
                <Box sx={tabPanelStyles.root}>
                    {children}
                </Box>
            )}
        </div>
    );
}