rn-emoji-keyboard
rn-emoji-keyboard copied to clipboard
fix: infinite loop on category swipe
This PR fixes infinite loop on quick emoji list scroll behavior reported in issue https://github.com/TheWidlarzGroup/rn-emoji-keyboard/issues/159
Changes:
- moved logic for scrolling emoji categories from useEffect hook to separate method
- passed said method into handleScrollToCategory method in Categories component and into SearchBar component to handle EmojiCategory list scrolling from children
In the previous implementation, after scrolling between EmojiCategories using gesture, when setActiveCategory
was called inside onScrollEnd
method, useEffect
callback with scrollToIndex
was fired with activeCategoryIndex
that the list was already at. Quick scrolling back and forth with gesture was causing infinite state updates between current and previous activeCategoryIndex
es. To fix that behavior while leaving ability to browse EmojiCategories using CategoryItem press scrollToIndex
is now called directly inside CategoryItem
@AnMiZa when you tap the search bar, does the list scroll to the search at the end? in my case it won't scroll after applying this pr.
Hey, @efstathiosntonas great catch! I was not aware of that functionality so I did not refactor it. I also had this loop bug when I was checking it out on master just now. Thanks for pointing that out, I will fix it tomorrow. I'll convert this PR to draft until then @jakex7.
@efstathiosntonas everything should work as intended now. Check it out.
@AnMiZa works as a charm. Thank you for jumping so fast in this and for this PR overall!
I'm also experiencing this and I'm glad that is already fixed, thank you so much 🙌
When is the next version going to be released?