Skip to content

Commit d04335e

Browse files
committed
Pass nextProps into calcTheme. Current implementation uses current props `theme` on update.
1 parent f7ac30d commit d04335e

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/components/themr.js

+14-14
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export default (componentName, localTheme, options = {}) => ThemedComponent => {
8484

8585
constructor(...args) {
8686
super(...args)
87-
this.theme_ = this.calcTheme()
87+
this.theme_ = this.calcTheme(this.props)
8888
}
8989

9090
getWrappedInstance() {
@@ -97,8 +97,8 @@ export default (componentName, localTheme, options = {}) => ThemedComponent => {
9797
return this.refs.wrappedInstance
9898
}
9999

100-
getNamespacedTheme() {
101-
const { themeNamespace, theme } = this.props
100+
getNamespacedTheme(props) {
101+
const { themeNamespace, theme } = props
102102
if (!themeNamespace) return theme
103103

104104
if (themeNamespace && !theme) {
@@ -119,9 +119,9 @@ export default (componentName, localTheme, options = {}) => ThemedComponent => {
119119
)
120120
}
121121

122-
getThemeNotComposed() {
123-
const { theme } = this.props
124-
if (theme) return this.getNamespacedTheme()
122+
getThemeNotComposed(props) {
123+
const { theme } = props
124+
if (theme) return this.getNamespacedTheme(props)
125125
if (config.localTheme) return config.localTheme
126126
return this.getContextTheme()
127127
}
@@ -132,23 +132,23 @@ export default (componentName, localTheme, options = {}) => ThemedComponent => {
132132
: {}
133133
}
134134

135-
getTheme() {
136-
const { composeTheme } = this.props
135+
getTheme(props) {
136+
const { composeTheme } = props
137137
return composeTheme === COMPOSE_SOFTLY
138138
? {
139139
...this.getContextTheme(),
140140
...config.localTheme,
141-
...this.getNamespacedTheme()
141+
...this.getNamespacedTheme(props)
142142
}
143143
: themeable(
144144
themeable(this.getContextTheme(), config.localTheme),
145-
this.getNamespacedTheme()
145+
this.getNamespacedTheme(props)
146146
)
147147
}
148148

149-
calcTheme() {
150-
const { composeTheme } = this.props
151-
return composeTheme ? this.getTheme() : this.getThemeNotComposed()
149+
calcTheme(props) {
150+
const { composeTheme } = props
151+
return composeTheme ? this.getTheme(props) : this.getThemeNotComposed(props)
152152
}
153153

154154
shouldComponentUpdate(nextProps) {
@@ -158,7 +158,7 @@ export default (componentName, localTheme, options = {}) => ThemedComponent => {
158158
theme !== nextProps.theme ||
159159
themeNamespace !== nextProps.themeNamespace
160160
) {
161-
this.theme_ = this.calcTheme()
161+
this.theme_ = this.calcTheme(nextProps)
162162
}
163163
return true
164164
}

0 commit comments

Comments
 (0)