MagazineContainer.js 1.44 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 magazineActions from '../reducers/magazine/magazineActions';

import Magazine from '../components/magazine/Magazine';


const actions = [
     magazineActions,
];

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 MagazineContainer extends Component {
    constructor(props) {
        super(props);
        this.onPressYohoNow = this.onPressYohoNow.bind(this);
    }

    onPressYohoNow(){
        ReactNative.NativeModules.YH_CommonHelper.searchYohoNow();
    }


    render() {

        return (
            <Magazine
                style={styles.container}
                onPressYohoNow={this.onPressYohoNow}
            />
        );
    }
}

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

});

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