We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
checkIndexBounds is too lenient and allows setting indexes from 0 .. count inclusive, whereas really the only valid values are 0 .. (count-1).
checkIndexBounds
0 .. count
0 .. (count-1)
react-swipeable-views/packages/react-swipeable-views-core/src/checkIndexBounds.js
Lines 9 to 12 in a12dd90
The warning is only produced after setting index to children.length + 1:
index
children.length + 1
Here is an example warning I see when I set index = 4 having only 3 children:
index = 4
Warning: react-swipeable-view: the new index: 4 is out of bounds: [0-3].
Setting index to exactly children.length should already produce a warning. The warning message should also show the correct range of values.
children.length
E.g. setting index to 3 should produce this warning when there are only 3 children:
3
Warning: react-swipeable-view: the new index: 3 is out of bounds: [0-2].
This should produce a warning, but it doesn't:
<SwipeableViews index={3}> <div>A</div> <div>B</div> <div>C</div> </SwipeableViews>
This is a minor dev nuisance, where the lenience of react-swipable-views is potentially allowing a dev to not detect code defects.
The text was updated successfully, but these errors were encountered:
Fix oliviertassinari#650: checkIndexBounds off by 1 validation
19676b2
Successfully merging a pull request may close this issue.
checkIndexBounds
is too lenient and allows setting indexes from0 .. count
inclusive, whereas really the only valid values are0 .. (count-1)
.react-swipeable-views/packages/react-swipeable-views-core/src/checkIndexBounds.js
Lines 9 to 12 in a12dd90
Current Behavior
The warning is only produced after setting
index
tochildren.length + 1
:Here is an example warning I see when I set
index = 4
having only 3 children:Expected Behavior
Setting
index
to exactlychildren.length
should already produce a warning. The warning message should also show the correct range of values.E.g. setting
index
to3
should produce this warning when there are only 3 children:Steps to Reproduce
This should produce a warning, but it doesn't:
Context
This is a minor dev nuisance, where the lenience of react-swipable-views is potentially allowing a dev to not detect code defects.
Your Environment
The text was updated successfully, but these errors were encountered: