1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00
next.js/client/next-dev.js
Naoyuki Kanezawa 0ef28ab128 Don't discard component state on error (#741)
* render debug page as overlay

* handle errors occurrred on rendering cycle for HMR

* retrieve props if required on HMR
2017-01-11 17:58:20 -08:00

23 lines
422 B
JavaScript

import patch from './patch-react'
// apply patch first
patch((err) => {
console.error(err)
Promise.resolve().then(() => {
onError(err)
})
})
require('react-hot-loader/patch')
const next = window.next = require('./')
next.default(onError)
function onError (err) {
// just show the debug screen but don't render ErrorComponent
// so that the current component doesn't lose props
next.render({ err })
}