leecade / react-native-swiper

The best Swiper component for React Native.
MIT License
10.42k stars 2.34k forks source link

Just don't use this lib. #1364

Open predrag-codetribe opened 1 year ago

predrag-codetribe commented 1 year ago

The last release was in 2020.

In my experience, there was plenty of bugs, which all lead to this lib...

predrag-codetribe commented 1 year ago

If anyone has a better, and maintained suggestion, feel free to leave a suggestion.

cicerotcv commented 1 year ago

Hello @predrag-codetribe, have you seen react-native-pager-view?

predrag-codetribe commented 1 year ago

Yes, have seen it but after the migration...

I migrated from leecade/react-native-swiper to https://github.com/gusgard/react-native-swiper-flatlist because the migration process was easy, and to avoid some bugs that I have encountered leecade/react-native-swiper.

I also enocuntered some minor bugs with https://github.com/gusgard/react-native-swiper-flatlist, like the onChangeIndex={({ index }) => setPage(index)} sometimes getting index out of sync... But managed to write some hacky code to fix that.

  const [page, setPage] = useState(0)
  const isLastPage = page === pack.length - 1

  useEffect(function HackToKeepThePageUpToDate() {
    // sometimes the onChangeIndex will not be called, thus the page is not updated
    // this useEffect should address that, and the page should always be up to date
    const interval = setInterval(() => {
      if (!swiperRef.current) return
      const index = swiperRef.current.getCurrentIndex()
      setPage(index)
    }, 1000)
    return () => clearInterval(interval)
  }, [])

Certainty I am open to find the a swipper component that "just works".

zykeee commented 2 weeks ago

If anyone has a better, and maintained suggestion, feel free to leave a suggestion.

@predrag-codetribe Try this: https://www.npmjs.com/package/@zzzzk/react-native-swiper