-
-
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
Fix objects with functions - replace (objToCss) with (objToCssArray) #2489
Fix objects with functions - replace (objToCss) with (objToCssArray) #2489
Conversation
This is great work, thanks! Out of interest, are there any performance metrics around a) objects/functions over template literals, and b) methods as properties? |
@mrmckeb I'm not 100% sure actually, but here is my understanding: Using objects gets converted by styled-components and it gets slower with nested objects because you have to go through every key for each object. So, based on my assumptions, using template literal is faster specially if the object contains nested objects. I would like to hear from somebody who is fully aware of the project to verify or correct me if i'm wrong. |
Good information, thanks @d7my11 - and great work. |
I'd also love if you could do this against |
@probablyup are there any minor releases for bugs before merging |
Yeah 4.x isn’t closed out yet
…On Thu, May 2, 2019 at 3:29 AM Abdel-Rhman ***@***.***> wrote:
@probablyup <https://github.com/probablyup> is there any minor releases
for bugs before merging canary into master? if so, will open a second PR
for this. If not, will change the base branch.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2489 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAELFVVLNTA4SWXAIFAMUM3PTKQ6XANCNFSM4HEWR53Q>
.
|
Will open another PR then |
If you could build it on top of @kitten's latest PR that'd be great as I think he made some changes to code near what you're changing |
@probablyup opened another PR for |
@d7my11 can you get this rebased against master? Looks like a test file just needs a little fix |
…ts into fix-object-with-methods
@probablyup done |
const rules = [] | ||
const keys = Object.keys(obj) | ||
|
||
keys |
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 would be cleaner as a reduce I think
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.
true, but it's slower than .forEach
because the result has a different type than the items. i did a quick benchmark for that here
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.
Fair enough!
Last thing, a changelog entry would be lovely |
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.
LGTM and thanks!
@probablyup thanks for reviewing |
Fixes: #2468
Addresses: #2414
The issue was in
objToCss
method that didn't handle methods for objects.objToCss
withobjToArray
which handles methods as well.createGlobalStyle
andstyled
with more test cases.