fix: Allow viewRegistry to accept subclasses of NSView #2196
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:
In React Native macOS, we have two "shim" classes to help make the iOS codebase of React Native compatible with macOS
RCTPlatformView
:a typedef ofNSView
on macOS, andUIView
on iOS / visionOS)RCTUIView
: A subclass ofNSView
with extra methods and properties to be closer to the iOSUIView
Additionally, in React Native's old architecture, there is this line that we forked as follows in 0.73 and earlier versions:
React Native:
React Native macOS:
In React Native macOS 0.74+, I changed the definition as follows, thinking the widening of scope to a superclass would be a non breaking change:
Turns out I was wrong, and this broke libraries like Reanimated and React Native Gesture Handler. The fix is simple, add a
__kindof
in front of the type!Test Plan:
Tested this in my branch where I'm adding macOS support to react-native-webgpu (wcandillon/react-native-webgpu#123), and reanimated + gesture gesture handler compile successfully.