Skip to content

Commit b85cd9e

Browse files
committed
docs: include dynamic styles in docs
1 parent 7fdaedc commit b85cd9e

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

docs/rules/no-unused-styles.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,23 @@ const Hello = React.createClass({
9595
}
9696
});
9797
```
98+
99+
Dynamic styles are marked as used only if you use a local variable with the same name as the variable in the actual component .
100+
101+
```js
102+
const getStyles = () => {
103+
const styles = StyleSheet.create({
104+
name: {}
105+
})
106+
return styles;
107+
}
108+
const Hello = React.createClass({
109+
render: function() {
110+
const styles = getStyles();
111+
return <Text textStyle={styles.name}>Hello {this.props.name}</Text>;
112+
}
113+
});
114+
```
98115
Rules are also marked as used when they are used in tags that contain the word `style`.
99116

100117
```js

0 commit comments

Comments
 (0)