react-native-navigation的迁移库

TextScreen.js 997B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import React, { Component } from 'react';
  2. import {
  3. StyleSheet,
  4. View,
  5. Text
  6. } from 'react-native';
  7. class TextScreen extends Component {
  8. render() {
  9. return (
  10. <View style={styles.root}>
  11. <Text style={styles.h1}>{this.props.text || 'Text Screen'}</Text>
  12. {this.renderTextFromFunctionInProps()}
  13. <Text style={styles.footer}>{`this.props.id = ${this.props.id}`}</Text>
  14. </View>
  15. );
  16. }
  17. renderTextFromFunctionInProps() {
  18. if (!this.props.myFunction) {
  19. return undefined;
  20. }
  21. return (
  22. <Text style={styles.h1}>{this.props.myFunction()}</Text>
  23. );
  24. }
  25. }
  26. const styles = {
  27. root: {
  28. flexGrow: 1,
  29. justifyContent: 'center',
  30. alignItems: 'center',
  31. backgroundColor: '#f5fcff'
  32. },
  33. h1: {
  34. fontSize: 24,
  35. textAlign: 'center',
  36. margin: 10
  37. },
  38. h2: {
  39. fontSize: 12,
  40. textAlign: 'center',
  41. margin: 10
  42. },
  43. footer: {
  44. fontSize: 10,
  45. color: '#888',
  46. marginTop: 10
  47. }
  48. };
  49. export default TextScreen;