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

createInertiaApp calls resolve with undefined name on browser navigation #2091

Open
cairin opened this issue Nov 14, 2024 · 0 comments
Open
Labels
react Related to the react adapter

Comments

@cairin
Copy link

cairin commented Nov 14, 2024

Version:

  • @inertiajs/react version: 1.2.0

Describe the problem:

resolvePageComponent from Laravel Vite Plugin is throwing Page not found: ./Pages/undefined.tsx.

This means createInertiaApp calls the resolve function with name undefined.

This seems to happen when navigating to a page that stores a form's data and errors in the history state, using the rememberKey.

Steps to reproduce:

  1. Create a new laravel app selecting the following options (I'm only showing possibly relevant ones here):
 ┌ Would you like to install a starter kit? ────────────────────┐
 │ Laravel Breeze                                               │
 └──────────────────────────────────────────────────────────────┘

 ┌ Which Breeze stack would you like to install? ───────────────┐
 │ React with Inertia                                           │
 └──────────────────────────────────────────────────────────────┘

 ┌ Would you like any optional features? ───────────────────────┐
 │ Inertia SSR                                                  │
 │ TypeScript                                                   │
 └──────────────────────────────────────────────────────────────┘
  1. Open resources/js/Pages/Auth/Login.tsx and add a rememberKey to the useForm hook on line 17:
    const { data, setData, post, processing, errors, reset } = useForm('login-form', {
  1. Start your dev server php artisan serve and npm run dev
  2. Go directly to http://localhost:8000/login.
  3. Click to go back in your browser.
  4. Click to go forward in your browser.
  5. The following error is logged to console (But the page still loads):
laravel-vite-plugin_inertia-helpers.js?v=f3c759dc:12 Uncaught (in promise) Error: Page not found: ./Pages/undefined.tsx
    at resolvePageComponent (laravel-vite-plugin_inertia-helpers.js?v=f3c759dc:12:9)
    at resolve (app.tsx:14:16)
    at C.l [as resolveComponent] (@inertiajs_react.js?v=ae425fca:3768:141)
    at C.setPage (@inertiajs_react.js?v=ae425fca:3463:33)
    at C.handleBackForwardVisit (@inertiajs_react.js?v=ae425fca:3361:52)
    at C.init (@inertiajs_react.js?v=ae425fca:3318:167)
    at @inertiajs_react.js?v=ae425fca:3756:8
    at commitHookEffectListMount (chunk-PJEEZAML.js?v=c8d5d030:16915:34)
    at commitPassiveMountOnFiber (chunk-PJEEZAML.js?v=c8d5d030:18156:19)
    at commitPassiveMountEffects_complete (chunk-PJEEZAML.js?v=c8d5d030:18129:17)

Notes

  • This doesn't seem to happen when navigating using a Link component, but does if the user routes to that path directly (if you change the <Link> to an <a>, or type the URL of the page with the form in the search bar).
  • It only fails when navigating away and back to the page with the form, not on the initial page load.
  • It doesn't happen when the useForm hook doesn't have a rememberKey.
  • It doesn't seem to have any effect on the end-user experience 🤷 but the Sentry spam was enough for me to create this issue.
@cairin cairin added the react Related to the react adapter label Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
react Related to the react adapter
Projects
None yet
Development

No branches or pull requests

1 participant