next-page-tester / next-page-tester

DEPRECATED - DOM integration testing for Next.js
MIT License
622 stars 28 forks source link

React 18 support: use hydrateRoot #301

Closed paul-pro closed 2 years ago

paul-pro commented 2 years ago

With the React 18 update some of the API methods were replaced, so usage of

const {render} = await getPage({route})
render()

produces following warning to the console:

Warning: ReactDOM.hydrate is no longer supported in React 18.
Use hydrateRoot instead. Until you switch to the new API, your app will behave as if it's running React 17.
Learn more: https://reactjs.org/link/switch-to-createroot
toomuchdesign commented 2 years ago

Hi @paul-pro, since Next supports both React 17 & 18, a possible solution might consist of calling React's api through a wrapper which sniffs available React version.

Another approach could be restricting support to the most recent version.

jasonwilliams commented 2 years ago

Considering maintenance on this project is quite low I'd be in favour of just supporting the most recent version. I don't think we have the resources to deal with both 17 and 18 bugs.

wenjoy commented 2 years ago

How can this happen? The package.json requires "react": "^16.6.0 || ^17". I tried, even couldn't install next-page-tester in nextjs@^12.1 project.

jasonwilliams commented 2 years ago

@wenjoy see https://github.com/next-page-tester/next-page-tester/issues/303

wenjoy commented 2 years ago

@jasonwilliams Thanks, buddy. Should this issue be closed?