alexbrillant / react-native-deck-swiper

tinder like react-native deck swiper

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Functional Component ref is not working (swiperRef is undefined)

iamadityaaz opened this issue · comments

  const swiperRef = useRef();

<SwipeCards
          ref={swiperRef}
          cards={cards}
          renderCard={cardData => (
            <Card data={cardData} swiperRef={swiperRef} />
          )}
          keyExtractor={cardData => String(cardData.text)}
        />
        
    swiperRef is undefined.
    swiperRef.current is also undefined

But if I swipe on the card once then swiperRef.current.swipeNope() works.

Any progress on this? Gotta love how many open issues this package has...

use this and its work

const useSwiper = useRef();
const handleOnSwipedLeft = () => useSwiper.current.swipeLeft();
const handleOnSwipedTop = () => useSwiper.swipeTop();
const handleOnSwipedRight = () => useSwiper.current.swipeRight();

const handleOnSwipedLeft = () => useSwiper.current.swipeLeft();
const handleOnSwipedTop = () => useSwiper.swipeTop();
const handleOnSwipedRight = () => useSwiper.current.swipeRight();

this work for me. thank you