react-native-navigation的迁移库

MyComponent.js 689B

1234567891011121314151617181920212223242526272829303132
  1. const React = require('react');
  2. const { Component } = require('react');
  3. const { Text } = require('react-native');
  4. const { connect } = require('react-redux');
  5. const store = require('./MyStore');
  6. class MyComponent extends Component {
  7. render() {
  8. if (this.props.renderCountIncrement) {
  9. this.props.renderCountIncrement();
  10. }
  11. return this.renderText(this.props.printAge ? this.props.age : this.props.name);
  12. }
  13. renderText(txt) {
  14. return (
  15. <Text>{txt}</Text>
  16. );
  17. }
  18. }
  19. function mapStateToProps(state) {
  20. return {
  21. name: store.selectors.getName(state),
  22. age: store.selectors.getAge(state)
  23. };
  24. }
  25. module.exports = connect(mapStateToProps)(MyComponent);