-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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 support for first-class functions #1820
add support for first-class functions #1820
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.
Yes, great! It always bugged me that I needed to run the same function a few times to set different attributes.
Short and sweet changeset, too. 👍
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 simple and nice enough that I'm a small 👍 I probably won't use this a ton, but I can defo see why you'd want to use this.
/cc @probablyup for final approfval
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 looks great!
CHANGELOG.md
Outdated
})) | ||
``` | ||
|
||
This can be useful for destructuring the props of the styled component or for inserting logic for computing the styles from props. |
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.
Could you add a byline to this matching the previous entries?
@probablyup Ok, tried to match it more closely and make it more brief (since many of the recent entries are pretty brief). Let me know if this is better. |
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.
Perfect, thanks!
Thank you so much for helping us improve styled-components! Based on our Community Guidelines every person that has a PR of any kind merged is offered an invitation to the styled-components organization—that is you right now! Should you accept, you'll get write access to the main repository. (and a fancy |
Closes #1620
Inspired by @probablyup's comment, I checkout out #1732 to see if I could solve my problem in #1620. Turns out, it was really straightforward.
To get a feel for the syntax this enables:
or alternatively
This is particularly useful for DRYing up repetitive logic mapping props to styles and not having to repeatedly reference the props object.