The @Styles
decorator can be used as a decorator for a react component class.
The decorator creates a react-native StyleSheet (using StyleSheet.create
) and assigns it to the class' prototype with the name styles
.
This eliminates the need for an external styles
variable (allowing multiple components to be present in the same class with separate styles).
But also ensures that only one StyleSheet instance is created per-class and does not leak memory (as doing styles = StyleSheet.create(...);
within the class itself would do).
@Styles({
// ...
})
class Example extends PureComponent