leecade / react-native-swiper

The best Swiper component for React Native.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Not updating width/height while rotating device

arunraj-qburst opened this issue · comments

Hi,
I was trying the orientation change with the swiper and it is not updating properly.
Any help in this regard ?

is there any fix or a workaround for this issue by now? Experiencing the same problem.
@arunraj-qburst @leecade

same issue

have you tried passing width from Dimensions.width instead of using flex layout? @jeffreymendez1993

commented

My solution

const [swiperLayout, setSwiperLayout] = useState({ height: 0, width: 0 })

return (
    <View style={{ flex: 1 } onLayout={e => setSwiperLayout(e.nativeEvent.layout)}>
        <Swiper
          height={swiperLayout.height}
          width={swiperLayout.width}
        >