Skip to content

performance optimisations #12

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

Merged
merged 2 commits into from
Aug 19, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/components/themr.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,12 @@ export default (componentName, localTheme, options = {}) => (ThemedComponent) =>

function themeable(style = {}, theme) {
if (!theme) return style
return [ ...Object.keys(theme), ...Object.keys(style) ].reduce((result, key) => (
typeof theme[key] === 'string' && style[key] && theme[key].indexOf(style[key]) === -1
? { ...result, [key]: `${style[key]} ${theme[key]}` }
: { ...result, [key]: theme[key] || style[key] }
), {})
return Object.keys(theme).reduce((result, key) => (
Object.assign(result, { [key]:
style[key] && theme[key].indexOf(style[key]) === -1
? `${style[key]} ${theme[key]}`
: theme[key] || style[key]
})), style)
Copy link
Contributor

Choose a reason for hiding this comment

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

Now passed style is mutated in reduce so a theme which is in context gets mutated too.

Copy link
Author

@vectorsize vectorsize Aug 19, 2016

Choose a reason for hiding this comment

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

oops you are right @raveclassic, will fix that, hopefully it doesnt slow down much, thanks for keeping an eye on this!

Copy link
Author

Choose a reason for hiding this comment

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

did a quick fix, still performs better, here:
https://github.com/javivelasco/react-css-themr/pull/13/files

Copy link
Owner

Choose a reason for hiding this comment

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

Sorry, honestly I did not dig deep before merging but I wanted to give a better look before releasing. Thanks for keeping an eye on it @raveclassic!

}

function validateComposeOption(composeTheme) {
Expand Down