Closed gfpacheco closed 1 year ago
I could re-set the state only if the length of the cards change if you think that's safer
@gfpacheco using getDerivedStateFromProps isn't really recommended and the swiper actually had it a while back and was removed for multiple reasons, one of which is performance. The current issue mentioned happens likely because there's a mix of state / props in the swiper when there should be only props.
I totally agree! I think the cards state is unnecessary, but I wanted to share the code that fixed the issue for me.
At the same time, we need to update the state whenever the cards prop changes (even before the render that changing it would cause), otherwise we might end up trying to read a card from an index that doesn't exist anymore.
getDerivedStateFromProps
also fixes an issue for me when the card is null
I'm new to this package, could you just make sure I didn't break anything else with this change?
I'm re-setting cards indexes and the cards state whenever the cards prop changes.