@@ -2,19 +2,13 @@ import 'babel-polyfill'
22import React from 'react'
33import { render } from 'react-dom'
44import { Provider } from 'react-redux'
5- import browserHistory from 'react-router/lib/browserHistory'
6- import Router from 'react-router/lib/Router'
75
86import _ from 'lodash'
97import store from './config/store'
10- import routes from './routes'
11- import { TCEmitter } from './helpers'
12- import { EVENT_ROUTE_CHANGE , SEGMENT_KEY } from './config/constants'
8+ import { SEGMENT_KEY } from './config/constants'
9+ import App from './App'
1310
1411const mountNode = document . getElementById ( 'root' )
15- const onRouteChange = ( ) => {
16- TCEmitter . emit ( EVENT_ROUTE_CHANGE , window . location . pathname )
17- }
1812
1913/* eslint-disable */
2014if ( ! _ . isEmpty ( SEGMENT_KEY ) ) {
@@ -25,8 +19,39 @@ if (!_.isEmpty(SEGMENT_KEY)) {
2519
2620/* eslint-enable */
2721
28- render ( (
29- < Provider store = { store } >
30- < Router history = { browserHistory } routes = { routes } onUpdate = { onRouteChange } />
31- </ Provider >
32- ) , mountNode )
22+ const renderApp = ( AppComponent ) => {
23+ render ( (
24+ < Provider store = { store } >
25+ < AppComponent />
26+ </ Provider >
27+ ) , mountNode )
28+ }
29+
30+ renderApp ( App )
31+
32+ /**
33+ * Warning from React Router, caused by react-hot-loader.
34+ * The warning can be safely ignored, so filter it from the console.
35+ * Otherwise you'll see it every time something changes.
36+ * See https://github.com/gaearon/react-hot-loader/issues/298
37+ *
38+ * I think if update to react-router it has to disappear
39+ */
40+ if ( module . hot ) {
41+ const isString = ( str ) => typeof str === 'string'
42+ const orgError = console . error // eslint-disable-line no-console
43+ console . error = ( ...args ) => { // eslint-disable-line no-console
44+ if ( args && args . length === 1 && isString ( args [ 0 ] ) && args [ 0 ] . indexOf ( 'You cannot change <Router routes>;' ) > - 1 ) {
45+ // React route changed
46+ } else {
47+ // Log the error as normally
48+ orgError . apply ( console , args )
49+ }
50+ }
51+
52+ module . hot . accept ( './App' , ( ) => {
53+ const AppComponent = require ( './App' ) . default
54+
55+ renderApp ( AppComponent )
56+ } )
57+ }
0 commit comments