Skip to content

Commit

Permalink
[test] Update hydration marker for React 17 (#16756)
Browse files Browse the repository at this point in the history
  • Loading branch information
Timer committed Sep 1, 2020
1 parent d20dbd6 commit 1c45f70
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
18 changes: 10 additions & 8 deletions packages/next/client/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,6 @@ class Container extends React.Component<{
}
)
}

if (process.env.__NEXT_TEST_MODE) {
window.__NEXT_HYDRATED = true

if (window.__NEXT_HYDRATED_CB) {
window.__NEXT_HYDRATED_CB()
}
}
}

componentDidUpdate() {
Expand Down Expand Up @@ -719,5 +711,15 @@ function Root({
// We use `useLayoutEffect` to guarantee the callback is executed
// as soon as React flushes the update.
React.useLayoutEffect(() => callback(), [callback])
if (process.env.__NEXT_TEST_MODE) {
// eslint-disable-next-line react-hooks/rules-of-hooks
React.useEffect(() => {
window.__NEXT_HYDRATED = true

if (window.__NEXT_HYDRATED_CB) {
window.__NEXT_HYDRATED_CB()
}
}, [])
}
return children as React.ReactElement
}
4 changes: 0 additions & 4 deletions test/acceptance/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ export async function sandbox(
env: { __NEXT_TEST_WITH_DEVTOOL: 1 },
})
const browser = await webdriver(appPort, '/')

// Slow down tests a bit to ensure application is ready:
await new Promise((resolve) => setTimeout(resolve, 750))

return [
{
sandboxDirectory,
Expand Down

0 comments on commit 1c45f70

Please sign in to comment.