Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: initial currentIndex render #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sergey-kozel
Copy link

The component renders incorrect when using initial currentIndex different than 0.

@felire
Copy link
Owner

felire commented Aug 22, 2023

Hey @sergey-kozel Thanks for the pr. Could you share a gif or video of how it works wrong when the curIndex is different that 0 and how it works with the change you made?

@@ -73,10 +73,10 @@ const CarouselDots = ({
const refScrollView = useRef<ScrollView>(null);
const [curIndex, setCurIndex] = useState<number>(currentIndex);
const positiveMomentum = useRef<boolean>(false);
const prevIndex = usePrevious(curIndex, curIndex);
const prevIndex = usePrevious(curIndex, curIndex - 1 >= 0 ? curIndex - 1 : curIndex);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need to set a prevValue that is the index minus 1? I mean, it would be 0 if the curIndex is 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants