Skip to content

Instantly share code, notes, and snippets.

@theapache64
Last active June 21, 2018 12:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theapache64/b1733719719b1e72575bc54b29f0b6e6 to your computer and use it in GitHub Desktop.
Save theapache64/b1733719719b1e72575bc54b29f0b6e6 to your computer and use it in GitHub Desktop.
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() {
let GreenText = React.cloneElement(this.getGreenText(),{
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