File size: 468 Bytes
7b71fb2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
import { useLocation } from 'umi';
export enum SegmentIndex {
Second = '2',
Third = '3',
}
export const useSegmentedPathName = (index: SegmentIndex) => {
const { pathname } = useLocation();
const pathArray = pathname.split('/');
return pathArray[index] || '';
};
export const useSecondPathName = () => {
return useSegmentedPathName(SegmentIndex.Second);
};
export const useThirdPathName = () => {
return useSegmentedPathName(SegmentIndex.Third);
};
|