react-native-navigation的迁移库

CustomTopBar.js 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. const React = require('react');
  2. const { Component } = require('react');
  3. const {
  4. StyleSheet,
  5. View,
  6. TouchableOpacity,
  7. Text,
  8. Alert,
  9. Platform
  10. } = require('react-native');
  11. class CustomTopBar extends Component {
  12. constructor(props) {
  13. super(props);
  14. this.state = {};
  15. }
  16. componentDidAppear() {
  17. console.log('RNN', 'CTB.componentDidAppear');
  18. }
  19. componentDidDisappear() {
  20. console.log('RNN', `CTB.componentDidDisappear`);
  21. }
  22. componentDidMount() {
  23. console.log('RNN', `CTB.componentDidMount`);
  24. }
  25. componentWillUnmount() {
  26. console.log('RNN', `CTB.componentWillUnmount`);
  27. }
  28. render() {
  29. return (
  30. <View style={styles.container}>
  31. <TouchableOpacity onPress={() => Alert.alert(this.props.title, 'Thanks for that :)')}>
  32. <Text style={styles.text}>Press Me</Text>
  33. </TouchableOpacity>
  34. </View>
  35. );
  36. }
  37. }
  38. module.exports = CustomTopBar;
  39. const styles = StyleSheet.create({
  40. container: {
  41. flex: 1,
  42. flexDirection: 'column',
  43. justifyContent: 'center',
  44. alignSelf: 'center'
  45. },
  46. text: {
  47. alignSelf: 'center',
  48. color: 'black',
  49. }
  50. });