Haggle.js 1.31 KB
'use strict';

import React from 'react';
import {AppRegistry} from 'react-native';
import createReactClass from 'create-react-class';

import {Provider} from 'react-redux';

import configureStore from './store/configureStore';

import haggleInitialState from './reducers/haggleListReducer/haggleInitialState';
import appInitialState from './reducers/app/appInitialState';

import HaggleListContainer from './containers/HaggleListContainer';
import {setHost, setPlatform, setServiceHost} from './reducers/app/appActions';

function getInitialState() {
    const _initState = {
        app: (new appInitialState()),
        haggle: (new haggleInitialState()),
    };
    return _initState;
}


export default function native(platform) {

    let YH_HaggleProductList = createReactClass({

        render() {
            const store = configureStore(getInitialState());
            store.dispatch(setPlatform(platform));
            store.dispatch(setHost(this.props.host));
            store.dispatch(setServiceHost(this.props.serviceHost));
            let type = this.props.type;
            return (
                <Provider store={store}>
                    <HaggleListContainer/>
                </Provider>
            );
        }
    });

    AppRegistry.registerComponent('YH_HaggleProductList', () => YH_HaggleProductList);
}