Skip to content

Commit

Permalink
fix remove useMemo usage
Browse files Browse the repository at this point in the history
  • Loading branch information
WaDadidou committed Sep 26, 2024
1 parent 72afc0d commit 2d4af42
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions packages/components/carousels/SmallCarousel/useSmallCarousel.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useMemo, useRef, useState } from "react";
import { useRef, useState } from "react";
import { StyleSheet } from "react-native";
import {
ICarouselInstance,
Expand Down Expand Up @@ -47,20 +47,16 @@ export const useSmallCarousel = (
}
};

const isPrevButtonEnabled = useMemo(
() =>
// The button always enabled if loop carousel
(isLoop ||
// If not loop, the button is disabled if the carousel is at start
currentIndex > 0) &&
// The button is always disabled if all items are visible (without doing next/prev)
data.length > step,
[isLoop, currentIndex, data.length, step],
);
const isNextButtonEnabled = useMemo(
() => (isLoop || currentIndex < data.length - 1) && data.length > step,
[isLoop, currentIndex, data.length, step],
);
const isPrevButtonEnabled =
// The button always enabled if loop carousel
(isLoop ||
// If not loop, the button is disabled if the carousel is at start
currentIndex > 0) &&
// The button is always disabled if all items are visible (without doing next/prev)
data.length > step;

const isNextButtonEnabled =
(isLoop || currentIndex < data.length - 1) && data.length > step;

return {
carouselRef,
Expand Down

0 comments on commit 2d4af42

Please sign in to comment.