Page MenuHomec4science

useTabs.js
No OneTemporary

File Metadata

Created
Sat, Jan 11, 05:49

useTabs.js

import * as React from 'react';
import { unstable_useControlled as useControlled, unstable_useId as useId } from '@mui/utils';
const useTabs = parameters => {
const {
value: valueProp,
defaultValue,
onChange,
orientation,
direction,
selectionFollowsFocus
} = parameters;
const [value, setValue] = useControlled({
controlled: valueProp,
default: defaultValue,
name: 'Tabs',
state: 'value'
});
const idPrefix = useId();
const onSelected = React.useCallback((e, newValue) => {
setValue(newValue);
if (onChange) {
onChange(e, newValue);
}
}, [onChange, setValue]);
const tabsContextValue = React.useMemo(() => {
return {
idPrefix,
value,
onSelected,
orientation,
direction,
selectionFollowsFocus
};
}, [idPrefix, value, onSelected, orientation, direction, selectionFollowsFocus]);
return {
tabsContextValue
};
};
export default useTabs;

Event Timeline