Use ThemeProvider theme instead of defaultProps theme - #345
Conversation
Generated by 🚫 dangerJS |
| const theme = this.props.theme || nextTheme | ||
| const { defaultProps } = this.constructor | ||
| const defaultTheme = defaultProps && defaultProps.theme | ||
| const isDefaultTheme = defaultTheme && this.props.theme === defaultTheme |
There was a problem hiding this comment.
Couldn't this be also const isDefaultTheme = this.props.theme === defaultTheme?
There was a problem hiding this comment.
You are right. I'm doing some small changes right now.
|
I made small changes on the code for better readability. Also added some comments (I'm not a big fan of it, but this |
mxstbr
left a comment
There was a problem hiding this comment.
Amazing, thanks so much! Will ship this asap
|
This still dosen't work as it should be, check this example: |
|
@ghalex Once you pass the prop from a normal component to a styled component ( But you can enhance component with |
|
Thanks @diegohaz I understand now why it only works if you pass defaultProps only directly to styled component. |
|
Another thing @diegohaz your example crashes in production when you have no ThemeProvider. Check this https://codesandbox.io/s/vr3q97or5 I have deployed it here: https://csb-vr3q97or5-ylvgjfxbld.now.sh/ and it crash. I think is related to this #1709 |
Fix #344