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 optional chaining to prevent history issue. #2189

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

danmatthews
Copy link

We've hit a strange bug where this particular line causes an issue after using Inertia::location() - it tries to read the page parameter of window.history.state which i'm assuming is reset during an Inertia::location() call?

Adding the optional chaining modifier (as already exists in another reference to this variable further up the page) would fix this for us.

We've hit a strange bug where this particular line causes an issue after using `Inertia::location()` - it tries to read the `page` parameter of `window.history.state` which i'm assuming is reset during an Inertia::location() call? 

Adding the optional chaining modifier (as already exists in another reference to this variable further up the page) would fix this for us.
@danmatthews
Copy link
Author

For context, we have an issue with the Svelte adapter, @inertiajs/svelte versions 2.0.0 and 2.0.1 that when we use an Inertia::location() call, it will trigger the following console error:

image

I can't reproduce this in a very minimal reproduction repo - seems to work fine, but likely because i'm not passing large amounts of props around like we are in our production app.

Hopefully this quick fix solves it for us without impacting any compatibility for any other adapters or the core as it's so small.

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.

1 participant