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.
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
Add STYLING.md to clarify styling best practices #2185
Add STYLING.md to clarify styling best practices #2185
Changes from all commits
bdeaa69
831ca61
fecc1fe
f76afef
f10089a
689bae5
0467521
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
This is all stemming from this conversation -> #1878 (comment)
I'm cool with whatever we decide to do as long as it's consistent
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.
Yeah, as stated in that other thread, I think that having the extra handling where a style can be an object or an array will be simpler than actually tying it to the plurality of the prop name. I have three reasons:
View
andPressable
can take either and object or array of styles, so having our components follow the same pattern is a good thing for consistency.StyleSheet.flatten
, and I think that's a pretty easy pattern to pick up on and remember. "If you have a style prop, flatten it!" The docs make me think there might be some performance implications of overusing that though, so maybe the tertiary pattern is better 🤷🏼♂️style
==Object
andstyles
==Array
might slip through the cracks and end up not being thoroughly enforced.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.
Nice thoughts.
I guess my concern with making all components behave like React Native components is that we'll always have to use a bunch of
StyleSheet.flatten()
everywhere and it makes adding styles to existing default styles kind of tricky.Maybe if we are going to standardize on something we can just do "always use an array"?
If extra style props are always arrays then we can spread them or pass them directly and don't have to handle different types.
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.
I like the idea of always standardizing on arrays. I think that solves the problem pretty nicely and makes it very clear how something should be done.
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.
Always using arrays is fine with me.