Skip to content

Commit 62524dd

Browse files
committed
feat: filter false props before generating styles
Prevents generating `undefined` style properties e.g `{ fontSize: '16px', fontFamily: undefined }` The above props would generate the following styles: ``` font-size: 16px; font-family: undefined; ``` The new feature is filtering false props before generating and injecting the styles. The new styles now look something like this: ``` font-size: 16px; ``` More details: styled-components#102
1 parent 2f2dd7b commit 62524dd

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/models/StyledComponent.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import css from '../constructors/css'
22
import normalizeProps from '../utils/normalizeProps'
3+
import removeFalseProps from '../utils/removeFalseProps'
34
import isVueComponent from '../utils/isVueComponent'
45

56
export default (ComponentStyle) => {
@@ -68,7 +69,10 @@ export default (ComponentStyle) => {
6869
},
6970
computed: {
7071
generatedClassName () {
71-
const componentProps = { theme: this.theme, ...this.$props }
72+
const componentProps = {
73+
theme: this.theme,
74+
...removeFalseProps(this.$props)
75+
}
7276
return this.generateAndInjectStyles(componentProps)
7377
},
7478
theme () {

0 commit comments

Comments
 (0)