mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
fix ConcurrentModificationException in ReactScrollViewHelper (#45550)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/45550 `ConcurrentModificationException` is happening from `emitScrollEvent()`. This usually happens if we modify the collection (add/remove) while accessing collection in a foreach loop. Seems likely add/remove is called from a different thread while in the foreach loop. Converting to list before we do the foreach as a quick fix. Changelog: [Internal] - quick fix for exception Issure reported here: https://fb.workplace.com/groups/rn.support/permalink/26557068097248454/ Reviewed By: mdvacca Differential Revision: D59991739 fbshipit-source-id: a2fcc798430acaadd07561a5be871967cc8f2c3b
This commit is contained in:
committed by
Facebook GitHub Bot
parent
aeb020dfa3
commit
3a5eb19731
+2
-2
@@ -113,7 +113,7 @@ public object ReactScrollViewHelper {
|
||||
return
|
||||
}
|
||||
val contentView = scrollView.getChildAt(0) ?: return
|
||||
for (scrollListener in scrollListeners) {
|
||||
for (scrollListener in scrollListeners.toList()) {
|
||||
scrollListener.onScroll(scrollView, scrollEventType, xVelocity, yVelocity)
|
||||
}
|
||||
val reactContext = scrollView.context as ReactContext
|
||||
@@ -146,7 +146,7 @@ public object ReactScrollViewHelper {
|
||||
/** This is only for Java listeners. onLayout events emitted to JS are handled elsewhere. */
|
||||
@JvmStatic
|
||||
public fun emitLayoutEvent(scrollView: ViewGroup) {
|
||||
for (scrollListener in scrollListeners) {
|
||||
for (scrollListener in scrollListeners.toList()) {
|
||||
scrollListener.onLayout(scrollView)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user