Closed maheraldous closed 1 year ago
your swipeCardsRef.current is null when you press the button. the timeout wouldn’t help. make sure your swiper ref is defined when you try to use it and you should be good
@webraptor but in the package example it always use swiper ref = null so how should I do what you say.
Can you write your edits to make it easier to understand.
I also getting the same error with Return button since ONLY after the last card swiped when I return it gives null error since there is no more card OR It gives me a loop again where the cards starts over.
So with other word as long as the cards not done I can use the return button as it supposed to be but not after the last card.
Fixed it by checking if swipeCardsRef.current
null
or not before making an action ith the button
const handleSwipeRight = () => {
if (!isSwiping) {
setDisableSwipeReturn(true);
if (swipeCardsRef.current) {
swipeCardsRef.current.swipeRight();
}
}
};
const handleSwipeLeft = () => {
if (!isSwiping) {
setDisableSwipeReturn(false);
if (swipeCardsRef.current) {
swipeCardsRef.current.swipeLeft();
}
}
};
const handleSwipeReturn = () => {
if (!isSwiping) {
setDisableSwipeReturn(true);
if (swipeCardsRef.current) {
swipeCardsRef.current.swipeBack();
}
}
if (isAllSwiped) {
setIsAllSwiped(false);
}
};
Hello I am getting these errors depending on the directions I swipe to.
ERROR TypeError: Cannot read property 'swipeRight' of null, js engine: hermes
ERROR TypeError: Cannot read property 'swipeLeft' of null, js engine: hermes
The errors dose not occur when swiping but it's appears when I swipe using buttons so something like the code below:
Those errors only appears when I swipe with buttons and very fast but not when I swipe very slow with buttons. I tried to set a timer for 1 seconds and more but no matter how long is the timer, I keep getting those errors when I press the buttons very fast.
I tried to create a clean test without adding so much stuff but the results still the same.