-
Notifications
You must be signed in to change notification settings - Fork 13
Closed
Labels
Description
All of the styles for a component should be self-contained within the component. This should make it pretty easy to identify styles that are defined but not actually used by the component, which would be a useful rule to have.
Bad:
function MyComponent({ styles }) {
return (
<div {...css(styles.foo)}>
Foo
</div>
);
}
export default withStyles(() => ({
foo: {
backgroundColor: 'red',
},
bar: { // <--- this style is not used
backgroundColor: 'green',
},
}))(MyComponent);Good:
function MyComponent({ styles }) {
return (
<div {...css(styles.foo)}>
Foo
</div>
);
}
export default withStyles(() => ({
foo: {
backgroundColor: 'red',
},
}))(MyComponent);