React-native-deck-swiper: Re-rendered Swiper seems to ignore cardIndex prop

Created on 5 Nov 2017  路  4Comments  路  Source: alexbrillant/react-native-deck-swiper

Hello, I'm lazy loading in forward and reverse. Initially, cards and cardIndex come from pieces of redux state.

When the state changes, the component is rendered again.

When the state changes to an array with new cards added to the end it works fine, my swiper has some new cards to swipe through, maybe because the index doesn't effectively change at this point.

However, when the state changes to an array with new cards added to the beginning, the cardIndex has to be adjusted of course, but cardIndex seems to be ignored when the render happens (after the first render).

Since redux will return a new array in the state and render will run, there doesn't seem to be an opportunity to use jumpToCardIndex anywhere in render(), unless I'm overlooking some different strategy of doing this?

Most helpful comment

componentWillReceiveProps now calculates the right card indexes

All 4 comments

Why do you need to add cards at the beginning of the array ?

There's a really large collection of items in a flat list, and you can select one to see the large version of it, and then the user can swipe through the collection moving either left or right, having started from any point.

componentWillReceiveProps now calculates the right card indexes

Amazing news thank you so much

Was this page helpful?
0 / 5 - 0 ratings