Rerendering card resets Swiper to first card
See original GitHub issuehow can i rerender a card, but not reset the Swiper to the first card ?
consider the following within the render function:
const cardData = this.state.cardData
const myCards = map(cardData, (card, cardIndex) => {
return (
<CardComponent
key={cardIndex}
prop={card.prop}
onEvent={this.onEvent}
/>
)
})
return (
<Swiper
ref={swiper => this.swiper = swiper}
cards={myCards}
cardVerticalMargin={0}
cardHorizontalMargin={0}
infinite={true}
renderCard={card => card}
backgroundColor={'transparent'}
verticalSwipe={false}
onSwiped={() => false}
onSwipedAll={() => false}
onSwipedLeft={() => false}
onSwipedRight={() => false}
></Swiper>
)
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Content of card does not render when state changed in react ...
Unfortunately the Swiper will not know whether to rerender itself if a state changes inside unless you swipe the card around which will ......
Read more >Swiper breaks when using Sprig - Craft CMS Stack Exchange
I am using Sprig to re-render some cards based on some parameters (with a dropdown filter). These cards also use Swiper to create...
Read more >Swiper API
Swiper is the most modern free mobile touch slider with hardware accelerated transitions and amazing native behavior.
Read more >Slow rendering - Android Developers
To fix jank, inspect which frames aren't completing in 16.7ms, and look for what is going wrong. Is Record View#draw taking abnormally long...
Read more >useMemo Hook - React Hooks Handbook - Design+Code
Create your first React app. 4:23 ... Re-rendering of the card. Now, this isn't really optimal, since the UserCard is a component that...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@bispul I fixed my issue by adding
cardIndex
to the state and then incrementing it in theonSwiped
callbackAh, ok … The bug is re-rendering and swiping will keep the second card to the second one in the original card deck, rather than the one you’ve swiped to so far … We’ve experienced this issue for about a month now, just created the PR with the fix. https://github.com/alexbrillant/react-native-deck-swiper/pull/76/files