mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
Use ReactDom.hydrate just for initial renderer. (#3012)
For other case just use ReactDom.render
This commit is contained in:
parent
846f734da3
commit
ee68d327fe
|
@ -123,9 +123,9 @@ export async function renderError (error) {
|
||||||
if (prod) {
|
if (prod) {
|
||||||
const initProps = { err: error, pathname, query, asPath }
|
const initProps = { err: error, pathname, query, asPath }
|
||||||
const props = await loadGetInitialProps(ErrorComponent, initProps)
|
const props = await loadGetInitialProps(ErrorComponent, initProps)
|
||||||
ReactDOM.hydrate(createElement(ErrorComponent, props), errorContainer)
|
renderReactElement(createElement(ErrorComponent, props), errorContainer)
|
||||||
} else {
|
} else {
|
||||||
ReactDOM.hydrate(createElement(ErrorDebugComponent, { error }), errorContainer)
|
renderReactElement(createElement(ErrorDebugComponent, { error }), errorContainer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,9 +151,19 @@ async function doRender ({ Component, props, hash, err, emitter }) {
|
||||||
|
|
||||||
// We need to clear any existing runtime error messages
|
// We need to clear any existing runtime error messages
|
||||||
ReactDOM.unmountComponentAtNode(errorContainer)
|
ReactDOM.unmountComponentAtNode(errorContainer)
|
||||||
ReactDOM.hydrate(createElement(App, appProps), appContainer)
|
renderReactElement(createElement(App, appProps), appContainer)
|
||||||
|
|
||||||
if (emitter) {
|
if (emitter) {
|
||||||
emitter.emit('after-reactdom-render', { Component, ErrorComponent })
|
emitter.emit('after-reactdom-render', { Component, ErrorComponent })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let isInitialRender = true
|
||||||
|
function renderReactElement (reactEl, domEl) {
|
||||||
|
if (isInitialRender) {
|
||||||
|
ReactDOM.hydrate(reactEl, domEl)
|
||||||
|
isInitialRender = false
|
||||||
|
} else {
|
||||||
|
ReactDOM.render(reactEl, domEl)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue