mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
Remove __next-error div (#5107)
`__next-error` is no longer needed as we always render in the `__next` div since a while.
This commit is contained in:
parent
673378e415
commit
254681d95a
|
@ -57,7 +57,6 @@ window.__NEXT_REGISTER_PAGE = pageLoader.registerPage.bind(pageLoader)
|
|||
|
||||
const headManager = new HeadManager()
|
||||
const appContainer = document.getElementById('__next')
|
||||
const errorContainer = document.getElementById('__next-error')
|
||||
|
||||
let lastAppProps
|
||||
let webpackHMR
|
||||
|
@ -148,6 +147,17 @@ export async function renderError (props) {
|
|||
await doRender({...props, err, Component: ErrorComponent, props: initProps})
|
||||
}
|
||||
|
||||
let isInitialRender = true
|
||||
function renderReactElement (reactEl, domEl) {
|
||||
// The check for `.hydrate` is there to support React alternatives like preact
|
||||
if (isInitialRender && typeof ReactDOM.hydrate === 'function') {
|
||||
ReactDOM.hydrate(reactEl, domEl)
|
||||
isInitialRender = false
|
||||
} else {
|
||||
ReactDOM.render(reactEl, domEl)
|
||||
}
|
||||
}
|
||||
|
||||
async function doRender ({ App, Component, props, hash, err, emitter: emitterProp = emitter }) {
|
||||
// Usual getInitialProps fetching is handled in next/router
|
||||
// this is for when ErrorComponent gets replaced by Component by HMR
|
||||
|
@ -167,9 +177,6 @@ async function doRender ({ App, Component, props, hash, err, emitter: emitterPro
|
|||
|
||||
emitterProp.emit('before-reactdom-render', { Component, ErrorComponent, appProps })
|
||||
|
||||
// We need to clear any existing runtime error messages
|
||||
ReactDOM.unmountComponentAtNode(errorContainer)
|
||||
|
||||
// In development runtime errors are caught by react-error-overlay.
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
renderReactElement((
|
||||
|
@ -193,14 +200,3 @@ async function doRender ({ App, Component, props, hash, err, emitter: emitterPro
|
|||
|
||||
emitterProp.emit('after-reactdom-render', { Component, ErrorComponent, appProps })
|
||||
}
|
||||
|
||||
let isInitialRender = true
|
||||
function renderReactElement (reactEl, domEl) {
|
||||
// The check for `.hydrate` is there to support React alternatives like preact
|
||||
if (isInitialRender && typeof ReactDOM.hydrate === 'function') {
|
||||
ReactDOM.hydrate(reactEl, domEl)
|
||||
isInitialRender = false
|
||||
} else {
|
||||
ReactDOM.render(reactEl, domEl)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,9 +14,9 @@ export default class Document extends Component {
|
|||
}
|
||||
|
||||
static getInitialProps ({ renderPage }) {
|
||||
const { html, head, errorHtml, buildManifest } = renderPage()
|
||||
const { html, head, buildManifest } = renderPage()
|
||||
const styles = flush()
|
||||
return { html, head, errorHtml, styles, buildManifest }
|
||||
return { html, head, styles, buildManifest }
|
||||
}
|
||||
|
||||
getChildContext () {
|
||||
|
@ -124,11 +124,10 @@ export class Main extends Component {
|
|||
}
|
||||
|
||||
render () {
|
||||
const { html, errorHtml } = this.context._documentProps
|
||||
const { html } = this.context._documentProps
|
||||
return (
|
||||
<Fragment>
|
||||
<div id='__next' dangerouslySetInnerHTML={{ __html: html }} />
|
||||
<div id='__next-error' dangerouslySetInnerHTML={{ __html: errorHtml }} />
|
||||
</Fragment>
|
||||
)
|
||||
}
|
||||
|
|
|
@ -138,11 +138,10 @@ async function doRender (req, res, pathname, query, {
|
|||
|
||||
let html
|
||||
let head
|
||||
let errorHtml = ''
|
||||
|
||||
try {
|
||||
if (err && dev) {
|
||||
errorHtml = render(<ErrorDebug error={err} />)
|
||||
html = render(<ErrorDebug error={err} />)
|
||||
} else if (err) {
|
||||
html = render(app)
|
||||
} else {
|
||||
|
@ -152,7 +151,7 @@ async function doRender (req, res, pathname, query, {
|
|||
head = Head.rewind() || defaultHead()
|
||||
}
|
||||
|
||||
return { html, head, errorHtml, buildManifest }
|
||||
return { html, head, buildManifest }
|
||||
}
|
||||
|
||||
await Loadable.preloadAll() // Make sure all dynamic imports are loaded
|
||||
|
|
Loading…
Reference in a new issue