-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Closed
Description
When StyleProvider theme is changed it does not get propagated to the ConnectedComponents(components that are decorated with connectStyle). After some debugging I found this issue is due to a bug in native-base-shoutem-theme connectStyle.js, specifically getOrSetStylesInCache method.
getOrSetStylesInCache(context, props, styleNames, path) {
if (themeCache && themeCache[path.join('>')]) {
// console.log('**************');
return themeCache[path.join('>')];
} else {
resolvedStyle = this.resolveStyle(context, props, styleNames);
if (Object.keys(themeCache).length < 10000) {
themeCache[path.join('>')] = resolvedStyle;
}
return resolvedStyle;
}
}
Looks like it is using the cached version of the theme for current component. The fix is to
remove the if block that is looking for the cached version of the style for the current component. The cache is still used for lookup of parent styles.
getOrSetStylesInCache(context, props, styleNames, path) {
resolvedStyle = this.resolveStyle(context, props, styleNames);
if (Object.keys(themeCache).length < 10000) {
themeCache[path.join('>')] = resolvedStyle;
}
return resolvedStyle;
}
I have a sample code to demonstrate this issue Github repo
elnygren, patrickgalbraith, aralmoro, elkwood, greyexpert and 9 more