Created
June 21, 2018 11:47
-
-
Save theapache64/72c974986ba0fac469e8abab1efb6efe to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { StyleSheet, Text, View } from 'react-native'; | |
export default class App extends React.Component { | |
getGreenText = () => { | |
return (<ColorText text="Default text" color="green"/>); | |
} | |
render() { | |
const GreenText = this.getGreenText(); | |
GreenText.text = "I am green text"; | |
return ( | |
<View style={styles.container}> | |
<ColorText color="red" text="I am red text"/> | |
{GreenText} | |
</View> | |
); | |
} | |
} | |
class ColorText extends React.Component{ | |
render(){ | |
return (<Text style={{color:this.props.color}}>{this.props.text}</Text>); | |
} | |
} | |
const styles = StyleSheet.create({ | |
container: { | |
flex: 1, | |
alignItems: 'center', | |
justifyContent: 'center', | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment