RecommondContainer.js 1.57 KB
'use strict'

import React, {Component} from 'react';
import ReactNative, {
    StyleSheet,
    Dimensions,
    Platform,
    View, 
    Text,
    NativeModules,
    InteractionManager,
    NativeAppEventEmitter,
    Alert,
} from 'react-native'

import {bindActionCreators} from 'redux';
import {connect} from 'react-redux';
import {Map} from 'immutable';
import * as recommondActions from '../reducers/recommond/recommondActions';
import Recommond from '../components/Recommond';

const actions = [
    recommondActions,
];
function mapStateToProps(state) {
    return {
        ...state
    };
}

function mapDispatchToProps(dispatch) {

    const creators = Map()
        .merge(...actions)
        .filter(value => typeof value === 'function')
        .toObject();

    return {
        actions: bindActionCreators(creators, dispatch),
        dispatch
    };
}

class RecommondContainer extends Component {
    constructor(props) {
        super(props);
        this._onPressIcon = this._onPressIcon.bind(this);
    }

    _onPressIcon(index){
           console.log(index);
        ReactNative.NativeModules.YH_CommonHelper.shareAppById(index);
    }
    render() {
        let {recommond} = this.props;
        let {data} = recommond.recommondList;
        return (
          <Recommond
              style={styles.container}
              dataSource={data}
              onPressIcon = {this._onPressIcon}
          />
        );
    }

}

let styles = StyleSheet.create({
    container: {
        flex: 1,
    },

});

export default connect(mapStateToProps, mapDispatchToProps)(RecommondContainer);