Skip to content

Instantly share code, notes, and snippets.

@crrmacarse
Created May 15, 2020 02:25
Show Gist options
  • Save crrmacarse/e9bc4253b37bcb2746aa01dcde1d0b08 to your computer and use it in GitHub Desktop.
Save crrmacarse/e9bc4253b37bcb2746aa01dcde1d0b08 to your computer and use it in GitHub Desktop.
Preloading
import 'providers/message';
import 'core-js/stable';
import 'regenerator-runtime/runtime';
import 'raf/polyfill';
import 'scss/index.scss';
import 'providers/sentry';
import React from 'react';
import { hydrate } from 'react-dom';
import { Provider as ReduxProvider } from 'react-redux';
import Providers from 'providers';
import storeConfig from 'providers/store';
// import { loadableReady } from '@loadable/component';
import * as serviceWorker from 'providers/service-worker';
/* eslint-disable no-underscore-dangle */
const initialState = window && (window as any).__PRELOADED_STATE__;
delete (window as any).__PRELOADED_STATE__;
/* eslint-enable */
const initialStore = storeConfig(initialState);
const docRoot = document.getElementById('root');
const app = (
<ReduxProvider store={initialStore}>
<Providers />
</ReduxProvider>
);
hydrate(app, docRoot);
serviceWorker.register();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment