123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- import React, { Component } from 'react';
- import {
- StyleSheet,
- View,
- Text
- } from 'react-native';
-
- class TextScreen extends Component {
- render() {
- return (
- <View style={styles.root}>
- <Text style={styles.h1}>{this.props.text || 'Text Screen'}</Text>
- {this.renderTextFromFunctionInProps()}
- <Text style={styles.footer}>{`this.props.id = ${this.props.id}`}</Text>
- </View>
- );
- }
-
- renderTextFromFunctionInProps() {
- if (!this.props.myFunction) {
- return undefined;
- }
- return (
- <Text style={styles.h1}>{this.props.myFunction()}</Text>
- );
- }
- }
-
- const styles = {
- root: {
- flexGrow: 1,
- justifyContent: 'center',
- alignItems: 'center',
- backgroundColor: '#f5fcff'
- },
- h1: {
- fontSize: 24,
- textAlign: 'center',
- margin: 10
- },
- h2: {
- fontSize: 12,
- textAlign: 'center',
- margin: 10
- },
- footer: {
- fontSize: 10,
- color: '#888',
- marginTop: 10
- }
- };
-
- export default TextScreen;
|