react-native-navigation的迁移库

LifecycleScreen.js 1.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import React, { Component } from 'react';
  2. import { View, Text, Button } from 'react-native';
  3. import Navigation from 'react-native-navigation';
  4. class LifecycleScreen extends Component {
  5. constructor(props) {
  6. super(props);
  7. this.onClickPush = this.onClickPush.bind(this);
  8. this.state = {
  9. text: 'nothing yet'
  10. };
  11. }
  12. onStart() {
  13. this.setState({ text: 'onStart!' });
  14. }
  15. onStop() {
  16. alert('onStop!'); //eslint-disable-line
  17. }
  18. render() {
  19. return (
  20. <View style={styles.root}>
  21. <Text style={styles.h1}>{this.state.text}</Text>
  22. <Button title="Push to test onStop" onPress={this.onClickPush} />
  23. </View>
  24. );
  25. }
  26. onClickPush() {
  27. Navigation.on(this.props.id).push({
  28. name: 'navigation.playground.SimpleScreen'
  29. });
  30. }
  31. }
  32. export default LifecycleScreen;
  33. const styles = {
  34. root: {
  35. flexGrow: 1,
  36. justifyContent: 'center',
  37. alignItems: 'center',
  38. backgroundColor: '#f5fcff'
  39. },
  40. h1: {
  41. fontSize: 24,
  42. textAlign: 'center',
  43. margin: 10
  44. }
  45. };