-
Notifications
You must be signed in to change notification settings - Fork 24.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Web] Add Platform module for web target #23387
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check out Platform.ios for the proper flow typing of this file. Otherwise, yeah let's do this!
Why does this need to live in core? Do we need to have Platform files for all the platforms people make? |
@TheSavior the problem with this particular module is that libraries like Attempting to use something very unrelated like
A few modules have this same effect. |
While we should probably merge this just to unblock, I'd really like to have a solution that doesn't require all the platforms to add themselves to the core. Could you think about this and see if you can come up with a solution? :) |
In the case of Dimensions, it looks like Android is special cased because the object we get from the device is different on iOS than Android: Dimensions comes from native here: It seems like the platforms should be unified on the data they provide to JS so that it can be calculated consistently. At which point other platforms have a standard API to report dimensions through and it doesn't need platform checks. |
@TheSavior AFAIK this is (should be) the only place we define the platform
This paradigm seems fine. I think there should be a way to access Platform from within any module. I would rather fix Platform than change every internal module that uses it. |
For an example of how another out-of-tree platform does this: Fully agree with @TheSavior , figuring out a way to do this that doesn't require RN itself having a master list of all platforms is key. At my previous job, we were able to bundle RN Windows app using haul which is webpack underneath. Of course, I'm open to learning something if there's some counter-indication you have in your specific situation :D |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree we should figure out a long term plan but I don't think that's a reason to block landing this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cpojer is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
@EvanBacon merged commit daa79b0 into |
Summary
Added a Platform file for module for instances where internal modules need Platform.
ex:
react-native/Libraries/Utilities/Dimensions.js
Line 14 in 78be6ef
Changelog
Libraries/Utilities/Platform.web.js
[CATEGORY] [TYPE] - Message
Test Plan
everything should pass.