reactrondev / react-native-web-swiper

Swiper-Slider for React-Native and React-Native-Web
213 stars 55 forks source link

Issue and Fix: Components not getting prop updates #95

Closed OfficialDarkComet closed 1 year ago

OfficialDarkComet commented 1 year ago

When using the swiper my components did not respond to prop updates. However, I found the issue and saved the changes using package-patch. The problem was the props were not added to the cloned children of the swiper. Here is the fix for those interested and for the maintainer. Hope this helps!

Original:

{cloneElement(el, { activeIndex: this.getActiveIndex(), index: i, isActive: i === this.getActiveIndex() })}

Updated:

{cloneElement(el, { ...el.props, activeIndex: this.getActiveIndex(), index: i, isActive: i === this.getActiveIndex() })}
OfficialDarkComet commented 1 year ago

My bad... My post above is wrong (incorrect way to do cloneElement). Still unable to figure out the problem, unfortunately.