-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
53 lines (43 loc) · 1.4 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import React from 'react';
import { render } from 'react-dom';
import { HashRouter } from 'react-router-dom';
import { I18nextProvider} from 'react-i18next';
import { createStore, applyMiddleware, combineReducers, compose } from 'redux';
import { Provider } from 'react-redux';
import { routerReducer } from 'react-router-redux';
import thunk from 'redux-thunk'
import Component, {store, actions, reducers} from 'btm_src';
import i18n from './i18n';
let testData = {}
try {
testData = require('btm_test').default;
} catch (e){
console.error ('could not load test data')
}
const root = document.getElementById('root')
root.className = 'theme-dark';
const testReducers = reducers || {
test: (state, action) => ({
...testData,
...state
})
}
const middlewares = [thunk]
const composeEnhancers = typeof window !== 'undefined' && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const testStore = store || createStore(combineReducers({
...testReducers,
router: routerReducer
}), composeEnhancers(applyMiddleware(...middlewares)))
if (actions) {
console.error('ACTIONS', actions)
Object.values(actions).map(a => testStore.dispatch(a.FETCH()))
}
render(
<HashRouter>
<I18nextProvider i18n={i18n}>
<Provider store={testStore}>
<Component {...testData} />
</Provider>
</I18nextProvider>
</HashRouter>,
root);