Skip to content
This repository has been archived by the owner on Dec 13, 2018. It is now read-only.

Commit

Permalink
Fixed nested themes not being republished on outer theme changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Andarist committed Dec 21, 2017
1 parent cb6de3a commit f96a56a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/theme-provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ class ThemeProvider extends React.Component {

setOuterTheme = theme => {
this.outerTheme = theme
this.publishTheme()
}

publishTheme(theme) {
this.broadcast.setState(this.getTheme(theme))
}

componentDidMount() {
Expand All @@ -53,13 +58,12 @@ class ThemeProvider extends React.Component {
// set broadcast state by merging outer theme with own
if (this.context[CHANNEL]) {
this.setOuterTheme(this.context[CHANNEL].getState())
this.broadcast.setState(this.getTheme())
}
}

componentWillReceiveProps(nextProps) {
if (this.props.theme !== nextProps.theme) {
this.broadcast.setState(this.getTheme(nextProps.theme))
this.publishTheme(nextProps.theme)
}
}

Expand Down

0 comments on commit f96a56a

Please sign in to comment.