react-native-navigation的迁移库

component.js 745B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import React, { Component } from 'react';
  2. import { Text } from 'react-native';
  3. import { connect } from 'remx/react-native';
  4. import * as store from './store';
  5. class MyContainer extends Component {
  6. constructor(props) {
  7. super(props);
  8. }
  9. render() {
  10. if (this.props.renderCountIncrement) {
  11. this.props.renderCountIncrement();
  12. }
  13. if (this.props.printAge) {
  14. return this.renderText(this.props.age);
  15. } else {
  16. return this.renderText(this.props.name);
  17. }
  18. }
  19. renderText(txt) {
  20. return (
  21. <Text>{txt}</Text>
  22. );
  23. }
  24. }
  25. function mapStateToProps(ownProps) {
  26. return {
  27. name: store.getters.getName(),
  28. age: store.getters.getAge()
  29. };
  30. }
  31. export default connect(mapStateToProps)(MyContainer);