File tree Expand file tree Collapse file tree 3 files changed +13
-6
lines changed
test/integration/app-tree Expand file tree Collapse file tree 3 files changed +13
-6
lines changed Original file line number Diff line number Diff line change 1
1
import React from 'react'
2
2
import Link from 'next/link'
3
3
import { createContext } from 'react'
4
- // eslint-disable-next-line react/no-deprecated
5
- import { render } from 'react-dom'
4
+ import { flushSync } from ' react-dom'
5
+ import { createRoot } from 'react-dom/client '
6
6
import App , { AppContext } from 'next/app'
7
7
import { renderToString } from 'react-dom/server'
8
8
@@ -22,7 +22,9 @@ export default class MyApp extends App<{ html: string }> {
22
22
if ( typeof window !== 'undefined' ) {
23
23
const el = document . createElement ( 'div' )
24
24
document . querySelector ( 'body' ) ?. appendChild ( el )
25
- render ( toRender , el )
25
+ flushSync ( ( ) => {
26
+ createRoot ( el ) . render ( toRender )
27
+ } )
26
28
html = el . innerHTML
27
29
el . remove ( )
28
30
} else {
Original file line number Diff line number Diff line change 1
1
import React from 'react'
2
- // eslint-disable-next-line react/no-deprecated
3
- import { render } from 'react-dom'
2
+ import { flushSync } from ' react-dom'
3
+ import { createRoot } from 'react-dom/client '
4
4
import { renderToString } from 'react-dom/server'
5
5
import { NextPage } from 'next'
6
6
@@ -22,7 +22,9 @@ Page.getInitialProps = async ({ AppTree }) => {
22
22
if ( typeof window !== 'undefined' ) {
23
23
const el = document . createElement ( 'div' )
24
24
document . querySelector ( 'body' ) ?. appendChild ( el )
25
- render ( toRender , el )
25
+ flushSync ( ( ) => {
26
+ createRoot ( el ) . render ( toRender )
27
+ } )
26
28
html = el . innerHTML
27
29
el . remove ( )
28
30
} else {
Original file line number Diff line number Diff line change @@ -33,16 +33,19 @@ const runTests = () => {
33
33
const browser = await webdriver ( appPort , '/' )
34
34
let html = await browser . eval ( `document.documentElement.innerHTML` )
35
35
expect ( html ) . toMatch ( / p a g e : .* ?\/ / )
36
+ console . log ( 1 )
36
37
37
38
browser . elementByCss ( '#another' ) . click ( )
38
39
await waitFor ( waitTime )
39
40
html = await browser . eval ( `document.documentElement.innerHTML` )
40
41
expect ( html ) . toMatch ( / p a g e : .* ?\/ / )
42
+ console . log ( 2 )
41
43
42
44
browser . elementByCss ( '#home' ) . click ( )
43
45
await waitFor ( waitTime )
44
46
html = await browser . eval ( `document.documentElement.innerHTML` )
45
47
expect ( html ) . toMatch ( / p a g e : .* ?\/ a n o t h e r / )
48
+ console . log ( 3 )
46
49
} )
47
50
48
51
it ( 'should pass AppTree to NextPageContext' , async ( ) => {
You can’t perform that action at this time.
0 commit comments