React Native OOT platform API #1009
Replies: 2 comments 4 replies
-
|
+1 |
Beta Was this translation helpful? Give feedback.
-
|
I like the idea of separating the concepts of operating system and device category through Platform.OS and Platform.Variant. The proposed API seems easier to reason about than maintaining long lists of platform-specific checks, especially as React Native expands to TVs, desktop environments, and headsets. One concern I have is the potential for confusion between Platform.OS and Platform.Variant when developers decide which one to use. For example, some libraries may check for Android while others may check for mobile, even when they are trying to solve the same problem. It could be helpful to provide clear guidelines and examples describing when platform-specific behavior should rely on Platform.OS versus Platform.Variant. This may help keep ecosystem APIs more consistent as additional out-of-tree platforms are added. ;) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Adding notes and ideas here on defining the React Native core API for out-of-tree platform support. I'd really appreciate comments and feedback, to help firm these ideas up into something that could be submitted as an RFC.
(See “Formalize OOT platform concept (Vega, Desktop, TV, etc.)” in the list of projects in-flight in the React Foundation planning document. )
Requirements
Changes to Platform.OS values
Platform.OS:iosandroidmacoswindowswebnativenative(it isn’t really a platform in the same sense as the others, just a way for Metro to identify non-web components)tvosandroidtvvegavisionos(?)metaquest(?)webtv(?)platformand nativePlatform.OSPlatform.Variant
Platform.VariantAPI (similar toPlatform.OS) that returns whether we are on TV, desktop, etc.Platform.uiModeconstant.mobile(default)desktoptvheadsetwebPlatform.Variantwould be determined at runtime, the wayuiModeis determined for Android todayPlatform.Variant, have a namespace where all OOT platform specific APIs and components liveTVnamespace whereTVFocusGuideView,TVEventHandler, etc. would now liveDesktopnamespacereact-native-macosandreact-native-windowswould provide exactly identical APIs in theDesktopnamespacereact-native-tvosand Vega would do the same forTVBundle size considerations
Beta Was this translation helpful? Give feedback.
All reactions