react-native-navigation的迁移库

CustomRoundedButton.js 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. const { Navigation } = require('react-native-navigation');
  12. class CustomRoundedButton extends Component {
  13. constructor(props) {
  14. super(props);
  15. this.subscription = Navigation.events().bindComponent(this);
  16. this.state = {};
  17. }
  18. componentDidAppear() {
  19. console.log('RNN', 'CRB.componentDidAppear');
  20. }
  21. componentDidDisappear() {
  22. console.log('RNN', `CRB.componentDidDisappear`);
  23. }
  24. componentDidMount() {
  25. console.log('RNN', `CRB.componentDidMount`);
  26. }
  27. componentWillUnmount() {
  28. this.subscription.remove();
  29. console.log('RNN', `CRB.componentWillUnmount`);
  30. }
  31. render() {
  32. return (
  33. <View style={styles.container} key={'guyguy'}>
  34. <View style={styles.button}>
  35. <TouchableOpacity onPress={() => Alert.alert(this.props.title, 'Thanks for that :)')}>
  36. <Text style={styles.text}>{this.props.title}</Text>
  37. </TouchableOpacity>
  38. </View>
  39. </View>
  40. );
  41. }
  42. }
  43. module.exports = CustomRoundedButton;
  44. const styles = StyleSheet.create({
  45. container: {
  46. flex: 1,
  47. backgroundColor: 'transparent',
  48. flexDirection: 'column',
  49. justifyContent: 'center',
  50. alignItems: 'center'
  51. },
  52. button: {
  53. width: 40,
  54. height: 40,
  55. borderRadius: 20,
  56. backgroundColor: 'red',
  57. justifyContent: 'center',
  58. },
  59. text: {
  60. color: 'black',
  61. alignSelf: 'center'
  62. }
  63. });