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

Delay instantation of brcast in ThemeProvider so it can be inited wit… #365

Merged
merged 1 commit into from
Dec 22, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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