Make the GlobalStyleComponent call the base constructor with props. (#2321)

* Make the GlobalStyleComponent call the base constructor with props.

* Changelog tweak.

* Simplify Flow types.

* Add PR link to the changelog entry.
This commit is contained in:
Jayden Seric
2019-01-15 17:06:45 +11:00
committed by Evan Jacobs
parent 3e93a2f9c7
commit cd134dc591
2 changed files with 7 additions and 3 deletions

View File

@@ -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))

View File

@@ -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<GlobalStyleComponentPropsType, *> {
styleSheet: Object;
static globalStyle = style;
static styledComponentId = id;
constructor() {
super();
constructor(props: GlobalStyleComponentPropsType) {
super(props);
const { globalStyle, styledComponentId } = this.constructor;