Skip to content

Add platform hook for View style props #18100

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

Closed
wants to merge 1 commit into from
Closed

Add platform hook for View style props #18100

wants to merge 1 commit into from

Conversation

rozele
Copy link
Contributor

@rozele rozele commented Feb 26, 2018

Similar to the ViewPropTypes hook to allow customization of prop types for iOS and Android, it's also useful to allow platforms to override style prop types.

Motivation

(Write your motivation here.)

Test Plan

Run jest tests.

Related PRs

#15175

Release Notes

[GENERAL][ENHANCEMENT][MINOR][View] - Add platform hook for adding View style props

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. cla signed labels Feb 26, 2018
@hramos
Copy link
Contributor

hramos commented Feb 26, 2018

You asked elsewhere how this might impact the docs. Right now, elevation is documented as part of the View Style Props docs. I've opened a PR on the docs repo with a proposal on how this might be documented: facebook/react-native-website#223

Similar to the `ViewPropTypes` hook to allow customization of prop types for iOS and Android, it's also useful to allow platforms to override style prop types.
@facebook-github-bot facebook-github-bot added the Import Started This pull request has been imported. This does not imply the PR has been approved. label Feb 26, 2018
Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hramos is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot facebook-github-bot added Import Failed and removed Import Started This pull request has been imported. This does not imply the PR has been approved. labels Feb 27, 2018
@facebook-github-bot
Copy link
Contributor

I tried to merge this pull request into the Facebook internal repo but some checks failed. To unblock yourself please check the following: Does this pull request pass all open source tests on GitHub? If not please fix those. Does the code still apply cleanly on top of GitHub master? If not can please rebase. In all other cases this means some internal test failed, for example a part of a fb app won't work with this pull request. I've added the Import Failed label to this pull request so it is easy for someone at fb to find the pull request and check what failed. If you don't see anyone comment in a few days feel free to comment mentioning one of the core contributors to the project so they get a notification.

@hramos
Copy link
Contributor

hramos commented Feb 27, 2018

It looks like with this change, some of our own internal apps are failing to build. I'll need to add this to my queue of diffs that need to be manually landed.

@sdwilsh sdwilsh removed the cla signed label Mar 1, 2018
@rozele
Copy link
Contributor Author

rozele commented Mar 3, 2018

@hramos - any luck?

@hramos
Copy link
Contributor

hramos commented Mar 5, 2018

I haven't gotten around to it yet. Some of our apps are failing to build with this error:

Invariant Violation: "elevation" is not a valid style property.

@rozele
Copy link
Contributor Author

rozele commented Mar 8, 2018

@hramos - I imagine this may be because the elevation prop is set on iOS even if it's not used.

@rozele
Copy link
Contributor Author

rozele commented Mar 9, 2018

@hramos - perhaps we just leave elevation in the original ViewStylePropTypes file, any chance you could produce an isolated repro of the tests so I can try to come up with a workaround? It seem either:

  1. We shouldn't produce errors when a platform-specific prop is set that isn't relevant to another platform.
  2. We should provide a simple syntax recommendation for setting a prop on only the relevant platform, something like:
...Platform.select({
  ios: {},
  android: {
    elevation: 1
  },
  windows: {}
})

@cpojer
Copy link
Contributor

cpojer commented Jan 29, 2019

We are currently working on getting rid of PropTypes altogether and using Flow Types to describe View props. I'm gonna close this PR and I'm sorry we didn't get to it earlier.

@hramos hramos added Merged This PR has been merged. and removed Import Failed labels Mar 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants