mirror of
https://github.com/zhigang1992/styled-components.git
synced 2026-01-12 22:52:39 +08:00
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:
committed by
Evan Jacobs
parent
3e93a2f9c7
commit
cd134dc591
@@ -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))
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user