From 0ed8562cfd9ca6be7a920a87ca6e31371cfb0443 Mon Sep 17 00:00:00 2001 From: ovaldi <232280074@qq.com> Date: Wed, 28 Nov 2018 10:31:20 +0800 Subject: [PATCH 1/2] bugfix: shouldComponentUpdate --- src/components/themr.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/themr.js b/src/components/themr.js index e1709c1..e3d7043 100644 --- a/src/components/themr.js +++ b/src/components/themr.js @@ -159,9 +159,8 @@ export default (componentName, localTheme, options = {}) => ThemedComponent => { themeNamespace !== prevProps.themeNamespace ) { this.theme_ = this.calcTheme() - return true } - return false + return true } render() { From 5db224e08b086e94069f0e9d517897d5820ff9c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20G=C3=BCnther?= Date: Wed, 5 Dec 2018 10:46:47 +0100 Subject: [PATCH 2/2] Fix: Use nextProps argument in shouldComponentUpdate The shouldComponentUpdate API defines that the arguments are nextProps and nextState. So we replace prevProps with nextProps. --- src/components/themr.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/themr.js b/src/components/themr.js index e3d7043..8022e8c 100644 --- a/src/components/themr.js +++ b/src/components/themr.js @@ -151,12 +151,12 @@ export default (componentName, localTheme, options = {}) => ThemedComponent => { return composeTheme ? this.getTheme() : this.getThemeNotComposed() } - shouldComponentUpdate(prevProps) { + shouldComponentUpdate(nextProps) { const { composeTheme, theme, themeNamespace } = this.props if ( - composeTheme !== prevProps.composeTheme || - theme !== prevProps.theme || - themeNamespace !== prevProps.themeNamespace + composeTheme !== nextProps.composeTheme || + theme !== nextProps.theme || + themeNamespace !== nextProps.themeNamespace ) { this.theme_ = this.calcTheme() }