Describe the bug
Using the latest Preact (10.7.1) and Next.js (12.1.4) and React 18 installed, changing the route (e.g. calling Router.replace, Router.push) will throw three errors:
- Error: Cancel rendering route
- TypeError: Cannot read properties of null (reading '__H')
- TypeError: Cannot read properties of null (reading '__H')
Next.js requires React to be installed (otherwise the server won't start), that's why I have it installed. With React 17, it works fine.
To Reproduce
Link: https://codesandbox.io/s/dank-frost-eeb42x
Also on GitHub: https://github.com/laymonage/repro-preact-nextjs-router-issue
Steps to reproduce the behavior:
- Go to https://codesandbox.io/s/dank-frost-eeb42x
- Click on the "Demonstrate the issue" button
- See error
Expected behavior
No errors
Notes
I don't know if this issue should be fixed in Next.js or Preact.
Possibly related: #3393, #3261