Skip to content
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

Add state null checks in history #2232

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

RSpeekenbrink
Copy link

@RSpeekenbrink RSpeekenbrink commented Feb 12, 2025

When switching from a non-inertia handled page to an inertia page in the same application the state object is not set. Thereby the getScrollRegions() and getDocumentScrollPosition() getters would generate the following error;

@inertiajs_react.js?v=387df219:3538 Uncaught (in promise) TypeError: Cannot read properties of null (reading 'scrollRegions')

This is fixed by adding null checks for history state.

Same goes for saveScrollPositions when the page object on state does not exist.

Fixes #2204

@RSpeekenbrink RSpeekenbrink changed the title Add state nullchecks on scroll state getters in history Add window.history.state null checks in history Feb 12, 2025
@RSpeekenbrink RSpeekenbrink changed the title Add window.history.state null checks in history Add state null checks in history Feb 12, 2025
@PNardman
Copy link

👍 waiting for this, since this is blocking inertia/nova upgrades in our project.

@RSpeekenbrink
Copy link
Author

@reinink is inertiaJS development suspended until further notice about the Laravel takeover? Would be nice to get some info about what's going on ❤️

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

Successfully merging this pull request may close these issues.

[Vue3] [React] window.history.state is null causing errors after upgrading to 2.0.3
2 participants