24ark / react-native-step-indicator

A simple react-native implementation of step indicator widget compatible with the ViewPager and ListView.
Apache License 2.0
1.44k stars 312 forks source link

Android Crashes with stepCount={1} #88

Closed interstates21 closed 4 years ago

interstates21 commented 4 years ago

image

Alyssa-McKee-Copart2 commented 4 years ago

Also encountering this on both iOS and Android. I have pages of varying lengths, and want to keep a visual consistency by always having the page count, even if there is only one page.

I believe this error is caused by

const animateToPosition = (this.state.progressBarSize/ (stepCount - 1)) * position;

in onCurrentPositionChanged

When stepCount is 1, then it is dividing by zero, which results in an invalid value for the progressBar width.

No progress bar should be needed if there is only 1 step.

rf1804 commented 4 years ago

@interstates21 @SilverInfinity waiting for my PR #84 to merge which resolves this issue @24ark

24ark commented 4 years ago

Version 1.0.3 should fix this issue: https://github.com/24ark/react-native-step-indicator/blob/1df202c5f819b58445c2b1b99a0e08dc8398f4e0/src/index.tsx#L399