Home.js 1.32 KB
'use strict';

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

import {
	Provider,
	connect
} from 'react-redux';

import configureStore from './store/configureStore';
import {Record, List, Map} from 'immutable';

import appInitialState from './reducers/app/appInitialState';
import homeInitialState from './reducers/home/homeInitialState';

import HomeContainer from './containers/HomeContainer';

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

import {
	loadChannelCachedData,
} from './reducers/home/homeActions';


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

export default function native(platform) {

	let YH_Home = createReactClass({

		render() {
			let channel = this.props.channelId;

		  	const store = configureStore(getInitialState());
			store.dispatch(setPlatform(platform));
			store.dispatch(setHost(this.props.host));
			store.dispatch(setServiceHost(this.props.serviceHost));
			store.dispatch(setChannel(channel))
			
			return (
				<Provider store={store}>
					<HomeContainer />
				</Provider>
			);
		}
	});

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