Repository navigation
fix(ios): skip an empty image name instead of looking it up - #1230
Open
rsoaresdev wants to merge 1 commit into
Open
rsoaresdev wants to merge 1 commit into
rsoaresdev wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
On the new architecture an action without an
imagestill reaches native code with one. The codegen spec declaresimage?: string, the generated C++ struct holds astd::stringthat defaults to empty, andios/NewArch/MenuView.mmalways puts it in the action dictionary:So
RCTMenuActionreceives"",UIImage(systemName: "")returns nil, and the fallbackUIImage(named: "")makes UIKit log this once for every action without an icon, each time the menu is built:A screen with a few menus prints it dozens of times. Nothing breaks (the image ends up nil, which is what an icon-less action wants), but it buries real messages in the Xcode console.
This skips the lookup when the name is empty, in
RCTMenuItem.swiftand inRCTAlertAction.swift(the iOS 13 action sheet path reads the same dictionary). The old architecture never sends an empty string, so its behaviour is unchanged, and a non-empty name is looked up exactly as before.Test Plan
MenuViewwith an action that has noimageand one that hasimage: "trash". Before, opening the menu logsCUICatalog: Invalid asset name supplied: ''; after, it does not, and thetrashsymbol still shows.UIImage(named:)as before.