Skip to content

Commit

Permalink
feat: add sanity check (duplicate tabs not allowed)
Browse files Browse the repository at this point in the history
  • Loading branch information
andreialecu committed Feb 7, 2021
1 parent 7038f63 commit 5e18678
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/hooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,12 @@ export function useTabProps<T extends TabName>(
throw new Error(
'Container children must be wrapped in a <Tabs.Tab ... /> component'
)

// make sure children is excluded otherwise our props will mutate too much
const { name, children, ...options } = element.props
if (tabOptions.has(name))
throw new Error(`Tab names must be unique, ${name} already exists`)

tabOptions.set(name, {
index,
name,
Expand Down

0 comments on commit 5e18678

Please sign in to comment.