mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
Bumping ESLint to the newest version. Related: #61525 Closes NEXT-2336
36 lines
795 B
TypeScript
36 lines
795 B
TypeScript
import React from 'react'
|
|
// eslint-disable-next-line react/no-deprecated
|
|
import { render } from 'react-dom'
|
|
import { renderToString } from 'react-dom/server'
|
|
import { NextPage } from 'next'
|
|
|
|
const Page: NextPage<{ html: string }> = ({ html }) =>
|
|
html ? (
|
|
<>
|
|
<p>saved:</p>
|
|
<div dangerouslySetInnerHTML={{ __html: html }} />
|
|
</>
|
|
) : (
|
|
<p>Hello world</p>
|
|
)
|
|
|
|
Page.getInitialProps = async ({ AppTree }) => {
|
|
let html: string
|
|
|
|
const toRender = <AppTree pageProps={{}} />
|
|
|
|
if (typeof window !== 'undefined') {
|
|
const el = document.createElement('div')
|
|
document.querySelector('body')?.appendChild(el)
|
|
render(toRender, el)
|
|
html = el.innerHTML
|
|
el.remove()
|
|
} else {
|
|
html = renderToString(toRender)
|
|
}
|
|
|
|
return { html }
|
|
}
|
|
|
|
export default Page
|