-
-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,3 @@ | ||
{ | ||
"presets": ["es2015", "react"], | ||
"env": { | ||
"development": { | ||
"presets": ["react-hmre"] | ||
} | ||
} | ||
"presets": ["es2015", "react"] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,43 @@ | ||
import 'babel-polyfill' | ||
import React from 'react' | ||
import { render } from 'react-dom' | ||
import ReactDOM from 'react-dom' | ||
import { Provider } from 'react-redux' | ||
import App from './containers/App' | ||
import configureStore from './store/configureStore' | ||
|
||
const store = configureStore() | ||
const rootEl = document.getElementById('root') | ||
|
||
render( | ||
<Provider store={store}> | ||
<App /> | ||
</Provider>, | ||
document.getElementById('root') | ||
) | ||
let render = () => { | ||
const App = require('./containers/App').default | ||
ReactDOM.render( | ||
<Provider store={store}> | ||
<App /> | ||
</Provider>, | ||
rootEl | ||
) | ||
} | ||
|
||
if (module.hot) { | ||
// Support hot reloading of components | ||
// and display an overlay for runtime errors | ||
const renderApp = render | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
gaearon
Author
Contributor
|
||
const renderError = (error) => { | ||
const RedBox = require('redbox-react') | ||
ReactDOM.render( | ||
<RedBox error={error} />, | ||
rootEl | ||
) | ||
} | ||
render = () => { | ||
try { | ||
renderApp() | ||
} catch (error) { | ||
renderError(error) | ||
} | ||
} | ||
module.hot.accept('./containers/App', () => { | ||
setTimeout(render) | ||
}) | ||
} | ||
|
||
render() |
Based on my experiment. This does not work well with react-router as it is. The react-router module prevents the changing of Routes once the Router is mounted. It gives the
Warning: [react-router] You cannot change <Router routes>; it will be ignored
message when trying to mount the app ontorootEl
. I was able to work around this issue by unmouting the whole app from the 'rooEl' and then rendering.I am not sure if this is okay and i am not sure it should be included in the example here.
Thank you for all contributions you've made. Redux made me re-think how i have been coding!!!