@@ -84,7 +84,7 @@ export default (componentName, localTheme, options = {}) => ThemedComponent => {
84
84
85
85
constructor ( ...args ) {
86
86
super ( ...args )
87
- this . theme_ = this . calcTheme ( this . props )
87
+ this . theme_ = this . calcTheme ( )
88
88
}
89
89
90
90
getWrappedInstance ( ) {
@@ -97,8 +97,8 @@ export default (componentName, localTheme, options = {}) => ThemedComponent => {
97
97
return this . refs . wrappedInstance
98
98
}
99
99
100
- getNamespacedTheme ( props ) {
101
- const { themeNamespace, theme } = props
100
+ getNamespacedTheme ( ) {
101
+ const { themeNamespace, theme } = this . props
102
102
if ( ! themeNamespace ) return theme
103
103
104
104
if ( themeNamespace && ! theme ) {
@@ -119,8 +119,9 @@ export default (componentName, localTheme, options = {}) => ThemedComponent => {
119
119
)
120
120
}
121
121
122
- getThemeNotComposed ( props ) {
123
- if ( props . theme ) return this . getNamespacedTheme ( props )
122
+ getThemeNotComposed ( ) {
123
+ const { theme } = this . props
124
+ if ( theme ) return this . getNamespacedTheme ( )
124
125
if ( config . localTheme ) return config . localTheme
125
126
return this . getContextTheme ( )
126
127
}
@@ -131,34 +132,38 @@ export default (componentName, localTheme, options = {}) => ThemedComponent => {
131
132
: { }
132
133
}
133
134
134
- getTheme ( props ) {
135
- return props . composeTheme === COMPOSE_SOFTLY
135
+ getTheme ( ) {
136
+ const { composeTheme } = this . props
137
+ return composeTheme === COMPOSE_SOFTLY
136
138
? {
137
- ...this . getContextTheme ( ) ,
138
- ...config . localTheme ,
139
- ...this . getNamespacedTheme ( props )
140
- }
139
+ ...this . getContextTheme ( ) ,
140
+ ...config . localTheme ,
141
+ ...this . getNamespacedTheme ( )
142
+ }
141
143
: themeable (
142
- themeable ( this . getContextTheme ( ) , config . localTheme ) ,
143
- this . getNamespacedTheme ( props )
144
- )
144
+ themeable ( this . getContextTheme ( ) , config . localTheme ) ,
145
+ this . getNamespacedTheme ( )
146
+ )
145
147
}
146
148
147
- calcTheme ( props ) {
148
- const { composeTheme } = props
149
+ calcTheme ( ) {
150
+ const { composeTheme } = this . props
149
151
return composeTheme
150
- ? this . getTheme ( props )
151
- : this . getThemeNotComposed ( props )
152
+ ? this . getTheme ( )
153
+ : this . getThemeNotComposed ( )
152
154
}
153
155
154
- componentWillReceiveProps ( nextProps ) {
156
+ shouldComponentUpdate ( prevProps ) {
157
+ const { composeTheme, theme, themeNamespace } = this . props
155
158
if (
156
- nextProps . composeTheme !== this . props . composeTheme ||
157
- nextProps . theme !== this . props . theme ||
158
- nextProps . themeNamespace !== this . props . themeNamespace
159
+ composeTheme !== prevProps . composeTheme ||
160
+ theme !== prevProps . theme ||
161
+ themeNamespace !== prevProps . themeNamespace
159
162
) {
160
- this . theme_ = this . calcTheme ( nextProps )
163
+ this . theme_ = this . calcTheme ( )
164
+ return true
161
165
}
166
+ return false
162
167
}
163
168
164
169
render ( ) {
0 commit comments