-
Notifications
You must be signed in to change notification settings - Fork 18
/
index.js
58 lines (43 loc) · 1.7 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import 'styles/bootstrap.scss'
import 'app.scss'
//to use generators
import 'regenerator-runtime/runtime'
// import 'core-js/library/es6/promise' //required for IE11
import 'isomorphic-fetch' //required for IE11 and Safary
//favicons
import 'public/img/favicon.ico'
import 'public/img/apple-touch-icon-152x152.png'
import 'public/img/apple-touch-icon-180x180.png'
import 'public/img/safari-pinned-tab.svg'
// // import React from 'react'
// if (process.env.NODE_ENV !== 'production') {
// const {whyDidYouUpdate} = require('why-did-you-update')
// whyDidYouUpdate(require('react'), { exclude: /.+Connect|Col|Week|Row|Day/})
// // whyDidYouUpdate(React, { exclude: /.+Calendar|Connect|TopNavbar|/ })
// // whyDidYouUpdate(React, { exclude: /.+Connect|TopNavbar|Week|Row|Col|/ })
// }
import 'utils/polyfills'
import { render } from 'react-dom'
import Grid from 'client/styles/grid.js'
import { getConfiguredWithStoreRouter } from './get-router.js'
let prevContainerWidth
let renderApp = function() {
const browserWidth = window.document.body.offsetWidth
const containerWidth = Grid.getContainerWidth(browserWidth)
if (containerWidth === prevContainerWidth) {
return
}
prevContainerWidth = containerWidth
render(getConfiguredWithStoreRouter(containerWidth), document.getElementById('root'))
}
window.addEventListener('resize', renderApp)
//first time render
renderApp()
// sending redux acdtion when browser size changes
import { setBrowserWidth } from 'shared/actions/actions'
import { getStore } from './get-router.js'
import { debounce } from 'lodash'
const store = getStore()
window.addEventListener('resize', debounce(() => store.dispatch(
setBrowserWidth(window.document.body.offsetWidth)
), 200))