I'm trying to create some reusable UI components for my React-Native app that have default styles.
An example default MyText
(orange, 14, bold):
import React, { Component, StyleSheet, Text } from 'react-native';
const styles = StyleSheet.create({text: {color: 'orange', fontSize: 14, fontWeight: 'bold'}});
export default class MyText extends Component {
render() {
return <Text style={styles.text}>{this.props.children}</Text>
}
}
How I would like to use it:
import Text from '../ui/myText';
...
<Text style={{color: 'black'}}>My custom styled text, but in black instead of orange</Text>
...
Is there a way to do this? Obviously if I try to access this.props.style
it just returns an ID for a compiled stylesheet.