Skip to content

Commit b2ad8e8

Browse files
committed
further cleanup
1 parent 529dc5c commit b2ad8e8

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/internal/interop/InteropUiBlockListener.kt

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,28 +38,32 @@ internal class InteropUIBlockListener : UIManagerListener {
3838
afterUIBlocks.add(block)
3939
}
4040

41+
@Synchronized
4142
override fun willMountItems(uiManager: UIManager) {
43+
if (beforeUIBlocks.isEmpty()) {
44+
return
45+
}
4246
// avoid ConcurrentModificationException by iterating over a copy
43-
try {
44-
if (uiManager is UIBlockViewResolver) {
45-
val snapshot = ArrayList(beforeUIBlocks)
46-
beforeUIBlocks.clear()
47-
snapshot.forEach { block ->
48-
block.execute(uiManager)
49-
}
47+
val snapshot = ArrayList(beforeUIBlocks)
48+
beforeUIBlocks.clear()
49+
if (uiManager is UIBlockViewResolver) {
50+
snapshot.forEach { block ->
51+
block.execute(uiManager)
5052
}
5153
}
5254
}
5355

56+
@Synchronized
5457
override fun didMountItems(uiManager: UIManager) {
58+
if (afterUIBlocks.isEmpty()) {
59+
return
60+
}
5561
// avoid ConcurrentModificationException by iterating over a copy
56-
try {
57-
if (uiManager is UIBlockViewResolver) {
58-
val snapshot = ArrayList(afterUIBlocks)
59-
afterUIBlocks.clear()
60-
snapshot.forEach { block ->
61-
block.execute(uiManager)
62-
}
62+
val snapshot = ArrayList(afterUIBlocks)
63+
afterUIBlocks.clear()
64+
if (uiManager is UIBlockViewResolver) {
65+
snapshot.forEach { block ->
66+
block.execute(uiManager)
6367
}
6468
}
6569
}

0 commit comments

Comments
 (0)