-
Notifications
You must be signed in to change notification settings - Fork 471
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
Deferred component throws error after a page (partial) reload #2221
Comments
Great, hope this pull request gets accepted soon! |
@KaioFelps , i have the same problem with inertia/vue in live, but locally everything is working |
@muhammedjafer does it also happen when you serve locally as if production (npm run build instead npm run dev)? I tested @inertiajs/vue3 |
@KaioFelps , i don't use deferred, not at all, locally when i do npm run build it works just fine but in the live it does not even though i run npm run build there too, |
I don't think this is related with this issue then, the problem described here is caused by |
Version:
@inertiajs/react
version: 2.0.3Describe the problem:
Currently, when using
Deferred
component in a page, if a navigation happens after the deferred props has loaded (e.g., a form submitting or another partial reload) theDeferred
children component causes an error by trying to access the property.My guess is: the new response overrides the page props, defining the deferred prop back to
undefined
, what leads to the error. Indeed, theDeferred
component swap the children component with the fallback in these cases, but by this time, the children component has already tried to "read a property of undefined" and caused the error.Indeed, using optional chaining to read the property from inside the children component (
someProp?.map(...)
) avoids the error and letDeferred
bring back the fallback while it refetches the deferred prop.Steps to reproduce:
If the page contains a
Deferred
component, a partial reload (triggered programmatically or by a form submission to a route that redirects back) can be enough to cause this error:The text was updated successfully, but these errors were encountered: