-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Documents StyleSheet.flatten() #6662
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
Documents StyleSheet.flatten() #6662
Conversation
Thanks! This is super useful. Do you mind adding a big warning at the top that this is not a recommended method and is an escape hatch. Style objects being opaque is required if we want to do optimizations down the line or work on the web by outputting classes, if you use this method, you are going to break this assumption. |
@prometheansacrifice updated the pull request. |
@vjeux Do you think the following is valid use case?
Basically, individual components nested within the child component, obtain their styles from |
You can do more simply: // Child
render() {
return <View style={[styles.defaultStyles, this.props.style]} />
} |
You don't need to flatten it at every step of the way, and really, you don't want to flatten it at every step of the way which is actually pretty expensive. You just want to forward it all the way down. If we can even get it unflattened all the way to React, then we can build good dev tools where we can display how the styles were combined and overridden like we have on web. |
@facebook-github-bot shipit |
Thanks for importing. If you are an FB employee go to Phabricator to review. |
@vjeux The issue with
both |
It is traditional to pass them as separate props.
Then you can just use |
I tried to document this use case here: http://facebook.github.io/react-native/docs/style.html#content |
@prometheansacrifice Why not |
@satya164 Sure. But open a new PR for this? |
@prometheansacrifice Why not :) |
Summary:Indicates the purpose and an alternative use for the method too. Closes facebook#6662 Differential Revision: D3099823 Pulled By: vjeux fb-gh-sync-id: 44633161a3df9b11d44afaed72fe6127f0b6bf7b fbshipit-source-id: 44633161a3df9b11d44afaed72fe6127f0b6bf7b
Indicates the purpose and an alternative use for the method too.