/** @module SZTMExcel */ // Import dependencies import React from 'react' import ReactDOM from 'react-dom' import { createStore, combineReducers, bindActionCreators, compose } from 'redux' import { Provider, connect } from 'react-redux' /** react-router is not used in this project. import { browserHistory, Router, Route, IndexRoute } from 'react-router' import { syncHistoryWithStore, routerReducer } from 'react-router-redux' */ // Import the main app import Main from './Main' // Import the submodules import player from './player' import match from './match' /** * Redux Section */ /** The root reducer is combined from all sub-module reducers */ const rootReducer = combineReducers({ player: player.reducer, match: match.reducer, }) console.log('Root reducer:', rootReducer) /** The default state is combined from all sub-module states */ const defaultState = { player: player.state, match: match.state, } console.log('Default state:', defaultState) /** The enhancer allows to use Redux development tools in Chrome */ const enhancers = compose( window.devToolsExtension ? window.devToolsExtension() : f => f ) console.log('Enhancers:', enhancers) /** Build the Redux store from the rootReducer, the defualtState and the enhancers. */ const store = createStore(rootReducer, defaultState, enhancers) console.log('Store:', store) /** react-route is not used in this project. const history = syncHistoryWithStore(browserHistory, store) console.log('history:', history) */ /** Collect the action creators from all modules in actionCreators */ const actionCreators = { player: player.actions, match: match.actions, } /** Creates a function */ function mapStateToProps (state) { const propState = {} Object.keys(state).forEach(key => { propState[key] = state[key] }) console.log('Mapping state to props:', state, propState) return propState } function mapDispatchToProps (dispatch) { const boundActionCreators = {} console.log('ActionCreators', actionCreators) Object.keys(actionCreators).forEach(key => { boundActionCreators[`${key}Actions`] = bindActionCreators(actionCreators[key], dispatch) }) console.log('Mapping dispatch to props:', dispatch, boundActionCreators) return boundActionCreators } const App = connect(mapStateToProps, mapDispatchToProps)(Main) /** * React-Router Section **/ /** Combine the routes from all modules. const router = ( {demo_module.routes} ) */ const provider = ( ) /** * Render the app **/ ReactDOM.render( provider, document.getElementById('root') )