import { useCallback , useState } from 'react' ; example export function useTabs < T extends string > ( defaultTab , ... possibleTabs ) { const [ currentTab , setTab ] = useState ( defaultTab ) ; const enum_ = { [ defaultTab ] : defaultTab } as any ; possibleTabs . forEach ( ( t ) => ( enum_ [ t ] = t ) ) ; const onChange = useCallback ( ( event , value ) => { setTab ( value ) ; } , [ ] ) ; return [ currentTab , onChange , enum_ , setTab ] as const ; }