fix: detect bare Switch host component name - #1932
Open
christophpurrer wants to merge 1 commit into
Open
Conversation
The iOS native component spec codegens under the name `Switch`, but `HOST_SWITCH_NAMES` only listed the legacy `RCTSwitch` name, so `isHostSwitch` returned `false` for elements with that host name. Add `Switch` alongside `RCTSwitch`, mirroring how `HOST_TEXT_NAMES` already accepts both `Text` and `RCTText`. See: react/react-native#58323
| // The iOS native component spec codegens under the name `Switch`, so the bare | ||
| // name has to be recognised alongside the legacy `RCTSwitch` one. | ||
| test('detects raw Switch component', async () => { | ||
| await render(React.createElement('Switch', { testID: 'switch' })); |
Member
There was a problem hiding this comment.
What does render? RCTSwitch? In real code how do you access that Switch with out RCT prefix?
Member
|
Does it affect any stable RN version? We have a nightly job running for every RN version, incl. latest, next and canary, that checks the following test: |
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.
Summary
The iOS native component spec codegens under the name
Switch, butHOST_SWITCH_NAMESonly listed the legacyRCTSwitchname, soisHostSwitchreturnedfalsefor elements with that host name.Add
SwitchalongsideRCTSwitch, mirroring howHOST_TEXT_NAMESalready accepts bothTextandRCTText.See: react/react-native#58323
Test plan
Added detects raw Switch component to src/tests/host-component-names.test.tsx. It fails on main and passes with this change. Full suite, typecheck, lint and format:check all pass.