Skip to content

Commit 1466e6e

Browse files
committed
fix: retain cycle
1 parent 8e8bfad commit 1466e6e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

packages/react-native-bottom-tabs/ios/TabViewProvider.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,11 +239,13 @@ public final class TabInfo: NSObject {
239239
}
240240

241241
private func loadIcons(_ icons: NSArray?) {
242+
guard let imageLoader else { return }
243+
242244
// TODO: Diff the arrays and update only changed items.
243245
// Now if the user passes `unfocusedIcon` we update every item.
244246
if let imageSources = icons as? [RCTImageSource?] {
245247
for (index, imageSource) in imageSources.enumerated() {
246-
guard let imageSource, let imageLoader else { continue }
248+
guard let imageSource else { continue }
247249
imageLoader.loadImage(
248250
with: imageSource.request,
249251
size: imageSource.size,
@@ -258,7 +260,8 @@ public final class TabInfo: NSObject {
258260
return
259261
}
260262
guard let image else { return }
261-
DispatchQueue.main.async {
263+
DispatchQueue.main.async { [weak self] in
264+
guard let self else { return }
262265
self.props.icons[index] = image.resizeImageTo(size: self.iconSize)
263266
}
264267
})

0 commit comments

Comments
 (0)