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

Commit

Permalink
fix: delay instantation of brcast in ThemeProvider so it can be inite…
Browse files Browse the repository at this point in the history
…d with correct initialState (#365)
  • Loading branch information
Andarist authored and Kent C. Dodds committed Dec 22, 2017
1 parent 8cd90bd commit 7468bfc
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/theme-provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import {CHANNEL} from './constants'
* @param {Object} theme the theme object..
*/
class ThemeProvider extends React.Component {
broadcast = brcast(this.props.theme)

// create theme, by merging with outer theme, if present
getTheme(passedTheme) {
const theme = passedTheme || this.props.theme
Expand All @@ -40,7 +38,9 @@ class ThemeProvider extends React.Component {

setOuterTheme = theme => {
this.outerTheme = theme
this.publishTheme()
if (this.broadcast !== undefined) {
this.publishTheme()
}
}

publishTheme(theme) {
Expand All @@ -59,6 +59,7 @@ class ThemeProvider extends React.Component {
if (this.context[CHANNEL]) {
this.setOuterTheme(this.context[CHANNEL].getState())
}
this.broadcast = brcast(this.getTheme(this.props.theme))
}

componentWillReceiveProps(nextProps) {
Expand Down

0 comments on commit 7468bfc

Please sign in to comment.