Skip to content

Commit e87dc0e

Browse files
committed
Use updateRule from jss
1 parent 0e45a63 commit e87dc0e

2 files changed

Lines changed: 3 additions & 17 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"homepage": "https://github.com/lttb/jss-styled#readme",
3535
"dependencies": {
3636
"is-react-prop": "^0.0.2",
37-
"jss": "^7.0.3",
37+
"jss": "^7.1.0",
3838
"jss-preset-default": "^2.0.0"
3939
},
4040
"peerDependencies": {

src/index.jsx

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,6 @@ export const createStyled = (jss?: Function = jssDefault) => (baseStyles: Object
3232
const elementStyles = {...styles, ...ownStyles}
3333
const dynamicStyles = getDynamicStyles(elementStyles)
3434

35-
const updateRule = (className, data) => {
36-
const componentRule = dynamicSheet.rules.map[className]
37-
38-
if (componentRule.type === 'regular') {
39-
for (const prop in componentRule.style) {
40-
const value = componentRule.style[prop]
41-
if (typeof value === 'function') {
42-
const computedValue = value(data)
43-
componentRule.prop(prop, computedValue)
44-
}
45-
}
46-
}
47-
}
48-
4935
const StaticTag = `${tag}-${++counter}`
5036

5137
return class StyledElement extends PureComponent {
@@ -82,13 +68,13 @@ export const createStyled = (jss?: Function = jssDefault) => (baseStyles: Object
8268
if (dynamicStyles && !dynamicSheet.getRule(this.tagScoped)) {
8369
dynamicSheet.detach()
8470
dynamicSheet.addRule(this.tagScoped, dynamicStyles)
85-
updateRule(this.tagScoped, this.props)
71+
dynamicSheet.update(this.tagScoped, this.props)
8672
dynamicSheet.attach()
8773
}
8874
}
8975

9076
componentWillReceiveProps(nextProps: StyledElementPropsT) {
91-
if (dynamicStyles) updateRule(this.tagScoped, nextProps)
77+
if (dynamicStyles) dynamicSheet.update(this.tagScoped, nextProps)
9278
}
9379

9480
componentWillUnmount() {

0 commit comments

Comments
 (0)