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

Commit

Permalink
feat(Root): add more flow typesm fix APP_INIT dispatch
Browse files Browse the repository at this point in the history
fix Application_init dispatch (remove innerWidth from payload)
use Date.now instead of Math.randow for react-redux <Provider>
add i18nConfigObject type
  • Loading branch information
Metnew committed Sep 17, 2017
1 parent a751f29 commit 8dc70ef
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions src/common/components/parts/Root/index.jsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
// @flow
import React, {Component} from 'react'
import {Provider} from 'react-redux'
import {IntlProvider, defineMessages, addLocaleData} from 'react-intl' // as we build ourself via webpack
import {IntlProvider, defineMessages, addLocaleData} from 'react-intl'
import {APPLICATION_INIT} from 'actions/common'
import {ThemeProvider} from 'styled-components'
import theme from 'styles/theme'
import App from 'containers/App'
import RoutingWrapper from 'components/addons/RoutingWrapper'
import {getWindowInnerWidth} from 'const'
import type {RouteItem} from 'types'
import type {RouteItem, i18nConfigObject} from 'types'

const Router = process.env.BROWSER
? require('react-router-redux').ConnectedRouter
: require('react-router').StaticRouter

type Props = {
store: Object,
i18n: {
messages: Object,
locale: string
},
i18n: i18nConfigObject,
SSR: {
location?: Object,
context?: Object
Expand All @@ -37,9 +33,8 @@ export default class Root extends Component {

componentWillMount () {
const {store, i18n} = this.props
const innerWidth: number = getWindowInnerWidth(window)
store.dispatch({type: APPLICATION_INIT, payload: {innerWidth}})
addLocaleData([...i18n.localeData])
store.dispatch({type: APPLICATION_INIT})
addLocaleData(i18n.localeData)
}

render () {
Expand All @@ -55,9 +50,9 @@ export default class Root extends Component {
locale={i18n.locale}
messages={defineMessages(i18n.messages)}
>
<Provider store={store} key={Math.random()}>
<Provider store={store} key={Date.now()}>
<ThemeProvider theme={theme}>
<Router {...routerProps} key={Math.random()}>
<Router {...routerProps}>
<App routes={routes}>
<RoutingWrapper store={store} routes={routes} />
</App>
Expand Down

0 comments on commit 8dc70ef

Please sign in to comment.