@@ -84,7 +84,7 @@ export default (componentName, localTheme, options = {}) => ThemedComponent => {
8484
8585 constructor ( ...args ) {
8686 super ( ...args )
87- this . theme_ = this . calcTheme ( this . props )
87+ this . theme_ = this . calcTheme ( )
8888 }
8989
9090 getWrappedInstance ( ) {
@@ -97,8 +97,8 @@ export default (componentName, localTheme, options = {}) => ThemedComponent => {
9797 return this . refs . wrappedInstance
9898 }
9999
100- getNamespacedTheme ( props ) {
101- const { themeNamespace, theme } = props
100+ getNamespacedTheme ( ) {
101+ const { themeNamespace, theme } = this . props
102102 if ( ! themeNamespace ) return theme
103103
104104 if ( themeNamespace && ! theme ) {
@@ -119,8 +119,9 @@ export default (componentName, localTheme, options = {}) => ThemedComponent => {
119119 )
120120 }
121121
122- getThemeNotComposed ( props ) {
123- if ( props . theme ) return this . getNamespacedTheme ( props )
122+ getThemeNotComposed ( ) {
123+ const { theme } = this . props
124+ if ( theme ) return this . getNamespacedTheme ( )
124125 if ( config . localTheme ) return config . localTheme
125126 return this . getContextTheme ( )
126127 }
@@ -131,34 +132,38 @@ export default (componentName, localTheme, options = {}) => ThemedComponent => {
131132 : { }
132133 }
133134
134- getTheme ( props ) {
135- return props . composeTheme === COMPOSE_SOFTLY
135+ getTheme ( ) {
136+ const { composeTheme } = this . props
137+ return composeTheme === COMPOSE_SOFTLY
136138 ? {
137- ...this . getContextTheme ( ) ,
138- ...config . localTheme ,
139- ...this . getNamespacedTheme ( props )
140- }
139+ ...this . getContextTheme ( ) ,
140+ ...config . localTheme ,
141+ ...this . getNamespacedTheme ( )
142+ }
141143 : themeable (
142- themeable ( this . getContextTheme ( ) , config . localTheme ) ,
143- this . getNamespacedTheme ( props )
144- )
144+ themeable ( this . getContextTheme ( ) , config . localTheme ) ,
145+ this . getNamespacedTheme ( )
146+ )
145147 }
146148
147- calcTheme ( props ) {
148- const { composeTheme } = props
149+ calcTheme ( ) {
150+ const { composeTheme } = this . props
149151 return composeTheme
150- ? this . getTheme ( props )
151- : this . getThemeNotComposed ( props )
152+ ? this . getTheme ( )
153+ : this . getThemeNotComposed ( )
152154 }
153155
154- componentWillReceiveProps ( nextProps ) {
156+ shouldComponentUpdate ( prevProps ) {
157+ const { composeTheme, theme, themeNamespace } = this . props
155158 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
159162 ) {
160- this . theme_ = this . calcTheme ( nextProps )
163+ this . theme_ = this . calcTheme ( )
164+ return true
161165 }
166+ return false
162167 }
163168
164169 render ( ) {
0 commit comments