79355124

Date: 2025-01-14 13:24:16
Score: 1
Natty:
Report link

This post has been taking dust for a while but just in case this could help anyone as me I will leave my fix.

I'm working swiper in React. When user navigate to a product, he can slide throughout different images. When user go to another product, the swiper images is initialized in the position of the previous product image swiper carousel.

I tried several approaches, using methods or initialSlide = 0, ... published in Swiper library, using customized ref for the swiper carousel, ... The only solution working was to add a key into the React component where is located the swiper carousel setting the value as the product.code. In that way React controls/handles updates for this component, not leaving in the virtual DOM with the previous status.

Hope someone could be helped with this strange behaviour.

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Low reputation (1):
Posted by: JuanmaDev