Permalink
Browse files

Merge pull request #1245 from digital-flowers/master

Add SSR PropTypes
  • Loading branch information...
mxstbr committed Oct 19, 2017
2 parents 8aa30c6 + e4f77e7 commit 43daf3b474e22fb10bcf18b91e4ff6ed4e50e1b2
Showing with 15 additions and 4 deletions.
  1. +1 −1 CHANGELOG.md
  2. +9 −2 src/models/StyleSheetManager.js
  3. +5 −1 src/models/StyledComponent.js
View
@@ -9,7 +9,7 @@ All notable changes to this project will be documented in this file. If a contri
- Prevent `withTheme` HOC from breaking when passing a theme from `defaultProps`, thanks to [@kutyel](https://github.com/kutyel) (see [#1130](https://github.com/styled-components/styled-components/pull/1130))
- Refactor out theme logic in StyledComponent's componentWillMount & componentWillReceiveProps (see [#1130](https://github.com/styled-components/styled-components/issues/1130))
- Add onReset to valid react props list (see [#1234](https://github.com/styled-components/styled-components/pull/1234))
- Add support for ServerStyleSheet PropType in both StyleSheetManager and StyledComponent (see [#1245](https://github.com/styled-components/styled-components/pull/1245))
## [v2.2.1] - 2017-10-04
@@ -2,6 +2,7 @@
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import StyleSheet, { CONTEXT_KEY } from './StyleSheet'
import ServerStyleSheet from './ServerStyleSheet'
class StyleSheetManager extends Component {
getChildContext() {
@@ -18,11 +19,17 @@ class StyleSheetManager extends Component {
}
StyleSheetManager.childContextTypes = {
[CONTEXT_KEY]: PropTypes.instanceOf(StyleSheet).isRequired,
[CONTEXT_KEY]: PropTypes.oneOfType([
PropTypes.instanceOf(StyleSheet),
PropTypes.instanceOf(ServerStyleSheet),
]).isRequired,
}
StyleSheetManager.propTypes = {
sheet: PropTypes.instanceOf(StyleSheet).isRequired,
sheet: PropTypes.oneOfType([
PropTypes.instanceOf(StyleSheet),
PropTypes.instanceOf(ServerStyleSheet),
]).isRequired,
}
export default StyleSheetManager
@@ -15,6 +15,7 @@ import type { RuleSet, Target } from '../types'
import { CHANNEL, CHANNEL_NEXT, CONTEXT_CHANNEL_SHAPE } from './ThemeProvider'
import StyleSheet, { CONTEXT_KEY } from './StyleSheet'
import ServerStyleSheet from './ServerStyleSheet'
const escapeRegex = /[[\].#*$><+~=|^:(),"'`]/g
const multiDashRegex = /--+/g
@@ -230,7 +231,10 @@ export default (ComponentStyle: Function, constructWithOptions: Function) => {
static contextTypes = {
[CHANNEL]: PropTypes.func,
[CHANNEL_NEXT]: CONTEXT_CHANNEL_SHAPE,
[CONTEXT_KEY]: PropTypes.instanceOf(StyleSheet),
[CONTEXT_KEY]: PropTypes.oneOfType([
PropTypes.instanceOf(StyleSheet),
PropTypes.instanceOf(ServerStyleSheet),
]),
}
static displayName = displayName

0 comments on commit 43daf3b

Please sign in to comment.