Skip to content

Instantly share code, notes, and snippets.

@ghernandez345
Last active July 10, 2017 13:41
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 ghernandez345/1e97ee96c20b0cd9c902b60bc39f7a8e to your computer and use it in GitHub Desktop.
Save ghernandez345/1e97ee96c20b0cd9c902b60bc39f7a8e to your computer and use it in GitHub Desktop.
React native parent dimensions dependent on child components
/* Use this pattern when you want your parent components dimension
* to be dependent by it's children components dimensions.
*/
const styles = StyleSheet.create({
container: {
flexDirection: 'row',
alignItems: 'center',
alignSelf: 'flex-start'
},
icon: {
// Any styles here
padding: 5
},
text: {
// Any styles here
padding: 5
}
});
const DynamicWidthAndHeightButton = () => (
<TouchableOpacity style={styles.container}>
<Icon style={styles.icon}/>
<Text style={styles.text}>dynamic width text here</Text>
</TouchableOpacity>
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment