I am trying to create some reusable user interface components for my React-Native application that have default styles.
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 any way to do this? Obviously, if I try to access this.props.style , it will simply return the identifier for the compiled stylesheet.
react-native
sflogen
source share