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

fixed withTheme #2033

Merged
merged 7 commits into from Oct 1, 2018

Conversation

Projects
None yet
4 participants
@theboyWhoCriedWoolf

theboyWhoCriedWoolf commented Sep 27, 2018

Updated withTheme to take default props from WrappedComponent. Fixes issues when ThemeProvider is not used but theme is defined in defaultProps.

Tal Woolf
@imbhargav5

This comment has been minimized.

Member

imbhargav5 commented Sep 28, 2018

Can we add a test case to this scenario? @theboyWhoCriedWoolf

Tal Woolf
@theboyWhoCriedWoolf

This comment has been minimized.

theboyWhoCriedWoolf commented Sep 28, 2018

Tests added, I also changed the determineTheme method to prevent it from throwing an error and stay consistent with previous functionality of just throwing a warning if no theme is there.

Happy to make further changes if required.

Thanks

@@ -9,8 +9,8 @@ export default (props: Props, fallbackTheme: any, defaultProps: any) => {

/* eslint-disable react/prop-types */
const isDefaultTheme = defaultProps ? props.theme === defaultProps.theme : false;

const theme = props.theme && !isDefaultTheme ? props.theme : fallbackTheme || defaultProps.theme;
const defaultPropsTheme = (defaultProps || {}).theme;

This comment has been minimized.

@probablyup

probablyup Sep 29, 2018

Contributor

Can you use EMPTY_OBJECT from utils/empties? And let's get rid of the extra variable allocation.

Tal Woolf and others added some commits Sep 30, 2018

@probablyup

Thank you!

@probablyup probablyup merged commit adfb557 into styled-components:develop Oct 1, 2018

1 check was pending

continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
@mxstbr

This comment has been minimized.

Member

mxstbr commented Oct 1, 2018

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 styled-components logo on your GitHub profile!) You'll be able to label and close issues, merge pull requests, create new branches, etc. We want you to help us out with those things, so don't be scared to do them! Make sure to read our contribution and community guidelines, which explains all of this in more detail. Of course, if you have any questions just let me know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment