Skip to content

Commit

Permalink
fix: allow initial value
Browse files Browse the repository at this point in the history
  • Loading branch information
SKairinos committed Jul 3, 2023
1 parent 3e74fef commit 13cee5f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/components/page/TabBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,24 @@ export interface TabBarProps {
path: string;
}>;
originalPath: string;
initialValue?: number;
}

const TabBar: React.FC<TabBarProps> = ({
header,
tabs,
originalPath
originalPath,
initialValue = 0
}) => {
const params = useParams();
const navigate = useNavigate();
const [value, setValue] = React.useState(0);
const [value, setValue] = React.useState(
initialValue < 0
? 0
: initialValue >= tabs.length
? tabs.length - 1
: initialValue
);

const labels = tabs.map(tab => tab.label);
const children = tabs.map(tab => tab.children);
Expand Down

0 comments on commit 13cee5f

Please sign in to comment.