Skip to content

Error: Cancel rendering route and TypeError: Cannot read properties of null (reading '__H') when using Next.js Router #3512

@laymonage

Description

@laymonage
  • Check if updating to the latest Preact version resolves the issue

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:

  1. Go to https://codesandbox.io/s/dank-frost-eeb42x
  2. Click on the "Demonstrate the issue" button
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions