Skip to content

Commit 1c45f70

Browse files
authoredSep 1, 2020
[test] Update hydration marker for React 17 (#16756)
1 parent d20dbd6 commit 1c45f70

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed
 

‎packages/next/client/index.tsx

+10-8
Original file line numberDiff line numberDiff line change
@@ -151,14 +151,6 @@ class Container extends React.Component<{
151151
}
152152
)
153153
}
154-
155-
if (process.env.__NEXT_TEST_MODE) {
156-
window.__NEXT_HYDRATED = true
157-
158-
if (window.__NEXT_HYDRATED_CB) {
159-
window.__NEXT_HYDRATED_CB()
160-
}
161-
}
162154
}
163155

164156
componentDidUpdate() {
@@ -719,5 +711,15 @@ function Root({
719711
// We use `useLayoutEffect` to guarantee the callback is executed
720712
// as soon as React flushes the update.
721713
React.useLayoutEffect(() => callback(), [callback])
714+
if (process.env.__NEXT_TEST_MODE) {
715+
// eslint-disable-next-line react-hooks/rules-of-hooks
716+
React.useEffect(() => {
717+
window.__NEXT_HYDRATED = true
718+
719+
if (window.__NEXT_HYDRATED_CB) {
720+
window.__NEXT_HYDRATED_CB()
721+
}
722+
}, [])
723+
}
722724
return children as React.ReactElement
723725
}

‎test/acceptance/helpers.js

-4
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ export async function sandbox(
3737
env: { __NEXT_TEST_WITH_DEVTOOL: 1 },
3838
})
3939
const browser = await webdriver(appPort, '/')
40-
41-
// Slow down tests a bit to ensure application is ready:
42-
await new Promise((resolve) => setTimeout(resolve, 750))
43-
4440
return [
4541
{
4642
sandboxDirectory,

0 commit comments

Comments
 (0)
Please sign in to comment.