Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Functional Component ref is not working (swiperRef is undefined) #362

Open
iamadityaaz opened this issue Jul 8, 2021 · 3 comments
Open

Comments

@iamadityaaz
Copy link

iamadityaaz commented Jul 8, 2021

  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.

@b-hexsoul
Copy link

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

@chandrabuw
Copy link

chandrabuw commented Oct 12, 2021

use this and its work

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

@Riaz5687
Copy link

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

this work for me. thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants