leecade / leecade/react-native-swiper
Swiper dynamic Push data in state (Nested array)
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 10.5k
- Forks
- 2.3k
- PR merge metrics
- No merged PRs in 30d
Description
Android
Version > 5
- react-native-swiper v1.6.0
- react-native v0.59
For example, I have nested array data:
** groups: [[],[],[],[]]
** Each slide is a group and each group have many items (item can be clicked and select, item selected will highlight)
** For example: I have 4 groups --- each group have 8 items (Index Active group/selected item: 2/4).
=> NOW: i change to 6 groups (setState) -- each group item have 6 items
** Expected: Index Active group/selected item: 3/2
** Actual: Index Active group/selected item: 0/2 (Always reset index to 0)
<Swiper
containerStyle={{ width: '100%' }}
ref={(component) => (this.swiper = component)}
key={groups.length}
loop={false}
autoplay={false}
showsButtons
showsPagination={false}
>
{groups.map((items) => {
return this.renderGroup(items);
})}
</Swiper>
Could anyone tell me how can solve this problem?
** I used group.length as key swiper
** Even I use scrollTo it still not work (when I switch between 4 and 6 groups)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the Swiper component shown in the issue and trace how changing the groups array and its key affects the active index. Reproduce switching between four and six groups and test whether scrollTo preserves the expected selection, with completion meaning the active group changes from 2/4 to 3/2 instead of resetting to 0/2.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react-native
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100