diff --git a/CHANGELOG.md b/CHANGELOG.md index d39a4af4..b0371681 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ _The format is based on [Keep a Changelog](http://keepachangelog.com/) and this ## Unreleased +- Make the `GlobalStyleComponent` created by `createGlobalStyle` call the base constructor with `props` (see [#2321](https://github.com/styled-components/styled-components/pull/2321)). + ## [v4.1.2] - 2018-11-28 - Fix function-form attrs to receive the full execution context (including theme) (see [#2210](https://github.com/styled-components/styled-components/pull/2210)) diff --git a/src/constructors/createGlobalStyle.js b/src/constructors/createGlobalStyle.js index 7b40a5da..5274c8c5 100644 --- a/src/constructors/createGlobalStyle.js +++ b/src/constructors/createGlobalStyle.js @@ -12,6 +12,8 @@ import css from './css'; import type { Interpolation } from '../types'; +type GlobalStyleComponentPropsType = Object; + // place our cache into shared context so it'll persist between HMRs if (IS_BROWSER) { window.scCGSHMRCache = {}; @@ -25,15 +27,15 @@ export default function createGlobalStyle( const id = `sc-global-${hashStr(JSON.stringify(rules))}`; const style = new GlobalStyle(rules, id); - class GlobalStyleComponent extends React.Component<*, *> { + class GlobalStyleComponent extends React.Component { styleSheet: Object; static globalStyle = style; static styledComponentId = id; - constructor() { - super(); + constructor(props: GlobalStyleComponentPropsType) { + super(props); const { globalStyle, styledComponentId } = this.constructor;