Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
jgettings committed Oct 7, 2024
1 parent 9d14e3c commit a1a4c4b
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/components/Carousel/Context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,11 @@ export const CarouselContextProvider: React.FC<CarouselContextProps> = ({
unsetSelected: () => setSelectedIndex(null),
hasNext,
navigateNext: () => setSelectedIndex((i) => (i === null ? null : i + 1)),
nextLabel:
selectedIndex === null || selectedIndex > items.length - 1
? ''
: getNavLabel(items[selectedIndex + 1]),
nextLabel: hasNext ? getNavLabel(items[selectedIndex + 1]) : '',
hasPrevious,
navigatePrevious: () =>
setSelectedIndex((i) => (i === null ? null : i - 1)),
previousLabel:
selectedIndex === null || selectedIndex < 1
? ''
: getNavLabel(items[selectedIndex - 1]),
previousLabel: hasPrevious ? getNavLabel(items[selectedIndex - 1]) : '',
}),
[getNavLabel, hasNext, hasPrevious, items, itemsByKeyField, selectedIndex],
);
Expand Down

0 comments on commit a1a4c4b

Please sign in to comment.