content: import React from 'react';
  import ReactDOM, { unmountComponentAtNode } from 'react-dom';
  import { AppContainer } from 'react-hot-loader';
  import { Provider } from 'react-redux';
  import createHistory from 'history/createBrowserHistory';
  import { ConnectedRouter } from 'react-router-redux';
  import { IntlProvider, addLocaleData } from 'react-intl';
  import Cookie from 'js-cookie';
  import axios from 'axios';
  
  import configureStore from './redux/store';
  
  // Get initial state from server-side rendering
  const initialState = window.__INITIAL_STATE__;
  const history = createHistory();
  const store = configureStore(history, initialState);
  const mountNode = document.getElementById('react-view');
  const locale = Cookie.get('locale') || 'en';
  
  const renderApp = (localeData) => {
    const App = require('./containers/App').default;
  
    const renderMethod = module.hot ? ReactDOM.render : ReactDOM.hydrate;
  
    renderMethod(
      <AppContainer>
        <Provider store={store}>
          <IntlProvider locale={locale} messages={localeData}>
            <ConnectedRouter history={history}>
              <App />
            </ConnectedRouter>
          </IntlProvider>
        </Provider>
      </AppContainer>,
      mountNode,
    );
  };
  
  axios.get(`/api/locale/${locale}`)
    .then((res) => {
      if (res.status >= 400) {
        throw new Error('Bad response from server');
      }
      return res.data;
    })
    .then((localeData) => {
      addLocaleData(window.ReactIntlLocaleData[locale]);
      renderApp(localeData);
    }).catch((e) => {
      console.error(e);
    });
  
  // Enable hot reload by react-hot-loader
  if (module.hot) {
    const reRenderApp = () => {
      try {
        axios.get(`/api/locale/${locale}`)
          .then((res) => {
            if (res.status >= 400) {
              throw new Error('Bad response from server');
            }
            return res.data;
          })
          .then((localeData) => {
            addLocaleData(window.ReactIntlLocaleData[locale]);
            renderApp(localeData);
          }).catch((e) => {
            console.error(e);
          });
      } catch (error) {
        const RedBox = require('redbox-react').default;
  
        const renderMethod = module.hot ? ReactDOM.render : ReactDOM.hydrate;
  
        renderMethod(<RedBox error={error} />, mountNode);
      }
    };
  
    module.hot.accept('./containers/App', () => {
      setImmediate(() => {
        // Preventing the hot reloading error from react-router
        unmountComponentAtNode(mountNode);
        reRenderApp();
      });
    });
  }
  
  if (process.env.NODE_ENV === 'production') {
    require('offline-plugin/runtime').install(); // eslint-disable-line global-require
  }
  