Skip to content

Commit

Permalink
Show initial errors too
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon committed Feb 29, 2016
1 parent c8bf9ef commit 745783d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
36 changes: 22 additions & 14 deletions examples/async/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,40 @@ import React from 'react'
import ReactDOM from 'react-dom'
import { Provider } from 'react-redux'
import configureStore from './store/configureStore'
import App from './containers/App'

const store = configureStore()
const rootEl = document.getElementById('root')

function render(rootReactEl) {
let render = () => {
const App = require('./containers/App').default
ReactDOM.render(
<Provider store={store}>
{rootReactEl}
<App />
</Provider>,
rootEl
)
}

render(<App />)

if (module.hot) {
module.hot.accept('./containers/App', () => {
const renderApp = render
const renderError = (error) => {
const RedBox = require('redbox-react')
const UpdatedApp = require('./containers/App').default
setTimeout(() => {
try {
render(<UpdatedApp />)
} catch (error) {
render(<RedBox error={error} />)
}
})
ReactDOM.render(
<RedBox error={error} />,
rootEl
)
}
render = () => {
try {
renderApp()
} catch (error) {
renderError(error)
}
}
module.hot.accept('./containers/App', (err) => {
console.error('hey', err)
setTimeout(render)
})
}

render()
1 change: 0 additions & 1 deletion examples/async/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ module.exports = {
plugins: [
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin()
],
module: {
loaders: [
Expand Down

0 comments on commit 745783d

Please sign in to comment.