Skip to content

Commit

Permalink
fix: select correct tab by default
Browse files Browse the repository at this point in the history
Fixes #108
  • Loading branch information
davwheat committed Jan 17, 2024
1 parent 971ff28 commit 7f267a8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/components/Tabs.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react'
import { Tabs as OGTabs, TabList, Tab, TabPanels, TabPanel } from '@reach/tabs'
import Breakpoints from '@data/breakpoints'
import styled from '@emotion/styled'

interface TabProps {
tabNames: string[]
Expand All @@ -11,17 +10,18 @@ interface TabProps {
onTabChange?: (index: number) => void
}

const MyTab = styled(Tab, { shouldForwardProp: prop => prop === 'children' })()

const Tabs = React.memo(({ tabNames, tabItems, customKeyPrefix = '', selectedTabIndex, onTabChange }: TabProps) => {
if (tabNames.length !== tabItems.length) {
throw new Error('Different amount of tabNames and tabItems provided.')
}

console.log('tabNames', tabNames)
console.log('tabItems', tabItems)

return (
<OGTabs
selectedIndex={selectedTabIndex}
onSelect={index => {
index={selectedTabIndex}
onChange={index => {
onTabChange?.(index)
}}
>
Expand Down

0 comments on commit 7f267a8

Please sign in to comment.