index.tsx 1.23 KB
Newer Older
David Haynes's avatar
David Haynes committed
1 2 3 4 5 6 7 8
/**
 * index.tsx
 *
 * The entry point for the application. Apply global styling, configure high
 * level (global application) settings and render <App />. Simple.
 */

// Apply Global Masonstrap styling
David Haynes's avatar
David Haynes committed
9 10
import 'masonstrap/build/css/masonstrap.min.css';
import 'masonstrap/build/js/masonstrap.min.js';
11 12
import * as React from 'react';
import * as ReactDOM from 'react-dom';
David Haynes's avatar
David Haynes committed
13 14 15
import { Provider } from 'react-redux';
import { applyMiddleware, compose, createStore } from 'redux';
import ReduxThunk from 'redux-thunk';
Andrew Hrdy's avatar
Andrew Hrdy committed
16
import App from './containers/App';
David Haynes's avatar
David Haynes committed
17
import { allReducers } from './reducers';
18

Andrew Hrdy's avatar
Andrew Hrdy committed
19 20 21 22 23 24 25 26
declare global {
    interface Window {
        __REDUX_DEVTOOLS_EXTENSION__?: () => any;
    }
}
const extension = window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__();
const isProduction = process.env.NODE_ENV === 'production';

David Haynes's avatar
David Haynes committed
27
let addOns;
Andrew Hrdy's avatar
Andrew Hrdy committed
28
if (isProduction || !extension) {
David Haynes's avatar
David Haynes committed
29
    addOns = compose(applyMiddleware(ReduxThunk));
Andrew Hrdy's avatar
Andrew Hrdy committed
30
} else {
David Haynes's avatar
David Haynes committed
31 32 33 34
    addOns = compose(
        applyMiddleware(ReduxThunk),
        extension
    );
Andrew Hrdy's avatar
Andrew Hrdy committed
35 36
}

37
// Attach all reducers + addOns to the Redux store
David Haynes's avatar
David Haynes committed
38
const store = createStore(allReducers, addOns);
Andrew Hrdy's avatar
Andrew Hrdy committed
39 40 41 42

ReactDOM.render(
    <Provider store={store}>
        <App />
David Haynes's avatar
David Haynes committed
43 44 45
    </Provider>,
    document.getElementById('root')
);