Skip to content

ERROR: window.history.state is null #713

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
adichannnnnhere64 opened this issue Feb 7, 2025 · 9 comments
Open

ERROR: window.history.state is null #713

adichannnnnhere64 opened this issue Feb 7, 2025 · 9 comments

Comments

@adichannnnnhere64
Copy link

I use SSR.
I use inertia v2
I use laravel octane

What's causing this? I can't see any fix in google.

Image

@im-aeo
Copy link

im-aeo commented Feb 8, 2025

I have the exact same thing happening to my site. I assume its a global issue.

@adichannnnnhere64
Copy link
Author

I have the exact same thing happening to my site. I assume its a global issue.

did you manage to fix it?

@adichannnnnhere64
Copy link
Author

adichannnnnhere64 commented Feb 14, 2025

clicking on an anchor tag trigger this error.

<a href="#" onClick> </a>

I removed it and it fixed the problem.

@mreduar
Copy link

mreduar commented Feb 25, 2025

I'm having a problem similar to this
Image

in fact the error occurs because window.history.state is null.
Image

@adichannnnnhere64
Copy link
Author

I'm having a problem similar to this Image

in fact the error occurs because window.history.state is null. Image

Yeah, I'm still randomly getting this error. I'm not sure how to reproduce it. When this error occurs, it freezes the site, and I can't navigate to any links.

@mreduar
Copy link

mreduar commented Feb 25, 2025

I think the error is related to this one.
inertiajs/inertia#2204

@milanchymcak
Copy link

@andrewperoramas I had the same issue with scrollRegions and fixed it like this for now, in your app.tsx:

if (!window.history.state) {
    window.history.replaceState({ scrollRegions: [] }, '');
}

@im-aeo
Copy link

im-aeo commented Mar 3, 2025

@andrewperoramas I had the same issue with scrollRegions and fixed it like this for now, in your app.tsx:

if (!window.history.state) {
window.history.replaceState({ scrollRegions: [] }, '');
}

I'll have to try that.

@jchmski
Copy link

jchmski commented Apr 6, 2025

@andrewperoramas I had the same issue with scrollRegions and fixed it like this for now, in your app.tsx:

if (!window.history.state) {
window.history.replaceState({ scrollRegions: [] }, '');
}

Thank you. I'm running into this same issue with inertiajs/inertia-laravel v2.0.1, and applying the above workaround to the app.jsx/tsx file resolved it.

For me, the error only triggers on certain pages on Chrome for android following these steps:

  1. Open the problematic page in the android chrome browser (it loads normally here)
  2. Go back to the android home screen
  3. swipe chrome out of the recent apps list
  4. Open chrome again

Upon chrome loading the same page opened in step 1, window.history.state is null causing the error Cannot read properties of null (reading 'scrollRegions') and I only see a blank page. If I reload the tab, it loads normally.

The proper fix has been applied in inertiajs/inertia, but no corresponding patch in the laravel package yet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants