Skip to content

Commit

Permalink
fix: add null check
Browse files Browse the repository at this point in the history
  • Loading branch information
andreialecu committed Feb 5, 2021
1 parent 1bea47b commit fb3b1b2
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/MaterialTabBar/TabBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,12 @@ const TabBar = <T extends TabName = any>({
return currentIndexToSync.value === targetIndexToSync.value
},
(canSync) => {
if (canSync && scrollEnabled && itemsLayout.length === nTabs) {
if (
canSync &&
scrollEnabled &&
itemsLayout.length === nTabs &&
itemsLayout[index.value]
) {
const halfTab = itemsLayout[index.value].width / 2
const offset = itemsLayout[index.value].x
if (
Expand Down

0 comments on commit fb3b1b2

Please sign in to comment.