From 795f50ffb65cd0c8634943ae9fc3c7faba08079a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Fri, 22 Dec 2017 12:12:28 +0100 Subject: [PATCH] Delay instantation of brcast in ThemeProvider so it can be inited with correct initialState --- src/theme-provider.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/theme-provider.js b/src/theme-provider.js index 523d84b1..6c958f18 100644 --- a/src/theme-provider.js +++ b/src/theme-provider.js @@ -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 @@ -40,7 +38,9 @@ class ThemeProvider extends React.Component { setOuterTheme = theme => { this.outerTheme = theme - this.publishTheme() + if (this.broadcast !== undefined) { + this.publishTheme() + } } publishTheme(theme) { @@ -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) {