Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
return defaultTheme;
};
type Props = {
styles: Styles,
// eslint-disable-next-line flowtype/no-weak-types
children: (classes: any) => React.Node
};
const createStylesCreator = (styles: Styles) =>
typeof styles === 'function' ? styles : (theme: mixed) => styles;
class JssStyled extends React.Component {
static contextTypes = {
[theming.channel]: PropTypes.object
};
static _sheetsManager = new Map();
_unsubscribe = null;
_theme = null;
_broadcast = brcast();
_stylesCreator;
get _inThemeContext() {
return !!this.context[theming.channel];
}
constructor(props: Props, context: mixed) {
super(props, context);
this._theme = this._getThemeFromContext() || getDefaultTheme();
componentDidMount() {
if (this._inThemeContext) {
this._unsubscribe = this.context[theming.channel].subscribe(theme => {
const oldTheme = this._theme;
this._theme = theme;
this._attach(this._theme);
this.forceUpdate(() => {
this._detach(oldTheme);
});
});
}
}
_getThemeFromContext = () =>
this.context[theming.channel] && this.context[theming.channel].getState();
_getThemeFromContext = () =>
this.context[theming.channel] && this.context[theming.channel].getState();