Skip to content
This repository has been archived by the owner on Jan 1, 2024. It is now read-only.

Commit

Permalink
fix(client): log initial state
Browse files Browse the repository at this point in the history
fix(client): log initial state
  • Loading branch information
Metnew committed Dec 5, 2017
1 parent 5e5c950 commit 50ba267
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/client/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import 'semantic-ui-css/components/loader.css'
import 'semantic-ui-css/components/reset.css'
import 'semantic-ui-css/components/sidebar.css'
import 'semantic-ui-css/components/site.css'
// Polyfills
// babel polyfill (ie 10-11) + fetch polyfill
import 'babel-polyfill'
import 'isomorphic-fetch'
// Application
Expand All @@ -29,19 +29,18 @@ import {hydrate} from 'react-dom'
import {AsyncComponentProvider} from 'react-async-component'
import asyncBootstrapper from 'react-async-bootstrapper'
import {configureApp, configureRootComponent} from 'common/app'
import {AppContainer} from 'react-hot-loader'
import type {GlobalState} from 'reducers'
import type {i18nConfigObject} from 'types'

if (process.env.NODE_ENV === 'production') {
require('common/pwa')
} else if (process.env.NODE_ENV === 'development') {
}

const initialState: GlobalState = window.__INITIAL_STATE__ || {}
const i18n: i18nConfigObject = window.__I18N__ || {}
const asyncState: Object = window.__ASYNC_STATE__ || {}
// NOTE: V8 doesn't optimize `delete`
// delete window.__INITIAL_STATE__

const {store, routes, history} = configureApp(initialState)
const RootComponent = configureRootComponent({
store,
Expand All @@ -51,12 +50,15 @@ const RootComponent = configureRootComponent({
})

const app = (
<AsyncComponentProvider rehydrateState={asyncState}>
{RootComponent}
</AsyncComponentProvider>
<AppContainer warnings={false}>
<AsyncComponentProvider rehydrateState={asyncState}>
{RootComponent}
</AsyncComponentProvider>
</AppContainer>
)

asyncBootstrapper(app).then(() => {
console.log('__INITIAL_STATE__:', initialState)
hydrate(app, document.getElementById('app'))
})

Expand Down

0 comments on commit 50ba267

Please sign in to comment.