react-use
react-use copied to clipboard
feat: support default initial index in useStateList , update tests and update docs
Description
Fixes : #2637
This PR adds support for initializing the useStateList hook with a default index addressing the issue #2637 .
You can now pass a second argument to useStateList to specify the initial index, e.g. useStateList(['a', 'b', 'c'], 1) will start at 'b'.
The test suite has been updated to cover this new behavior and ensure backward compatibility.
Type of change
- [x] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as before)
Checklist
- [x] Read the Contributing Guide
- [x] Perform a code self-review
- [x] Comment the code, particularly in hard-to-understand areas
- [x] Add documentation
- [ ] Add hook's story at Storybook
- [x] Cover changes with tests
- [x] Ensure the test suite passes (
yarn test) - [x] Provide 100% tests coverage
- [ ] Make sure code lints (
yarn lint). Fix it withyarn lint:fixin case of failure. - [x] Make sure types are fine (
yarn lint:types).