Functional Component ref is not working (swiperRef is undefined)
iamadityaaz opened this issue · comments
Aditya Prakash commented
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.
Brandon H commented
Any progress on this? Gotta love how many open issues this package has...
chandraklb commented
use this and its work
const useSwiper = useRef(); const handleOnSwipedLeft = () => useSwiper.current.swipeLeft(); const handleOnSwipedTop = () => useSwiper.swipeTop(); const handleOnSwipedRight = () => useSwiper.current.swipeRight();
Riaz Khan commented
const handleOnSwipedLeft = () => useSwiper.current.swipeLeft();
const handleOnSwipedTop = () => useSwiper.swipeTop();
const handleOnSwipedRight = () => useSwiper.current.swipeRight();
this work for me. thank you