Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

quickee's avatar

at resolvePageComponent Error - Cannot read properties of undefined

"@inertiajs/react": "^1.0.0", "@vitejs/plugin-react": "^4.0.3", LARAVEL v10.29.0

This issue just started happening. Test.jsx is in correct path, but pages[page] is undefined in the inertia-helpers. Any suggestions?

#path

resources /js / Pages /Test.jsx

#console error from app.jsx

laravel-vite-plugin_inertia-helpers.js?v=18a4faaf:5 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading './Pages/Test.jsx')
    at resolvePageComponent (laravel-vite-plugin_inertia-helpers.js?v=18a4faaf:5:21)
    at resolve (app.jsx:26:20)
    at f2 (@inertiajs_react.js?v=18a4faaf:3681:143)
    at U (@inertiajs_react.js?v=18a4faaf:3681:196)
    at app.jsx:23:1

#web


Route::get('/test', function () {
    return Inertia::render('Test');
})->name('test');

#app.jsx

import "./bootstrap";

import { createRoot } from "react-dom/client";
import { createInertiaApp } from "@inertiajs/react";
import { resolvePageComponent } from "laravel-vite-plugin/inertia-helpers";

const appName = import.meta.env.VITE_APP_NAME || "App";

createInertiaApp({
    title: (title) => `${title} - ${appName}`,
    resolve: (name) => {
      resolvePageComponent(`./Pages/Test.jsx`);
     
    },
         root.render(<div>test App.jsx</div>); },
});

#Test.jsx

import React, { useEffect } from "react";

const Test = () => {
    useEffect(() => {}, []);

    return <div>test Test.jsx</div>;
};
export default Test;

0 likes
10 replies
JussiMannisto's avatar

This issue just started happening. Test.jsx is in correct path, but pages[page] is undefined in the inertia-helpers. Any suggestions? #path resources js Pages Text.jsx

Which one is it: Test.jsx or Text.jsx?

Your resolve entry in app.jsx doesn't make much sense. I assume you edited the callback temporarily for debugging (?).

quickee's avatar

@JussiMannisto Sorry Typo - The naming is not the issue. Test.jsx is correct. thats right, I slimmed it down for debugging.

JussiMannisto's avatar

Your createInertiaApp call is completely wrong. The JS syntax is invalid, there's no setup call etc.

quickee's avatar

@JussiMannisto - I assure you my syntax is right. Sorry I will fix my initial post typos. The below still gets the same error.

createInertiaApp({
    title: (title) => `${title} - ${appName}`,
    resolve: (name) => {
        return resolvePageComponent(
            `./Pages/${name}.jsx`,
            import.meta.glob("./Pages/**/*.jsx")
        );
    },
 setup({ el, App, props }) {
      const root = createRoot(el);
     root.render(
      <App {...props} />
    );

});
JussiMannisto's avatar

@quickee

I assure you my syntax is right.

This is definitely NOT valid syntax:

createInertiaApp({
    title: (title) => `${title} - ${appName}`,
    resolve: (name) => {
      resolvePageComponent(`./Pages/Test.jsx`);
     
    },
         root.render(<div>test App.jsx</div>); },
});

What is root.render doing there? And what's that trailing }; behind it?

And the changed code is wrong too. There's no setup().

createInertiaApp({
    title: (title) => `${title} - ${appName}`,
    resolve: (name) => {
        return resolvePageComponent(
            `./Pages/${name}.jsx`,
            import.meta.glob("./Pages/**/*.jsx")
        );
    },
});
quickee's avatar

@JussiMannisto sir scroll up. the setup is there.

Also - the setup has nothing todo with the finding the page. I set a breakpoint in the intertia-helper @resolvePageComponent function. And the pages[page] is undefined. It never even makes it to the setup code. I know you are trying to help. But again, I assure you the syntax is correct.

I understand the initial post has TYPOS. And does not reflect the actual code. It was slimmed down for an easier understanding.

JussiMannisto's avatar

I see you modified the code in your previous post again. The syntax is still invalid: the setup call isn't closed:

createInertiaApp({
	title: (title) => `${title} - ${appName}`,
	resolve: (name) => {
		return resolvePageComponent(
			`./Pages/${name}.jsx`,
			import.meta.glob("./Pages/**/*.jsx")
		);
	},
	setup({ el, App, props }) {
		const root = createRoot(el);
		root.render(
			<App {...props} />
		);
	} // Add this closing bracket.
});
quickee's avatar

@JussiMannisto bro - it was edited before you even commented back. Man i've been programming for about 25 years. I understand you are convinced this is a syntax error. I promise you this is not the problem.

JussiMannisto's avatar

@quickee

I understand the initial post has TYPOS. And does not reflect the actual code. It was slimmed down for an easier understanding.

Your app doesn't work because you're doing something wrong. If you want help, post your actual code instead of making up stuff. Otherwise you're wasting everyone's time.

Check the InertiaJS docs below to see what's wrong with your setup. I can't help you further because I'm not psychic.

https://inertiajs.com/client-side-setup

quickee's avatar
quickee
OP
Best Answer
Level 1

@JussiMannisto it was intended to make it easier to read. And break off the pieces that didn't matter. Adding the await and return page.default || page; fixed it.

createInertiaApp({
    title: (title) => `${title} - ${appName}`,
    resolve: async (name) => {
        const page = await resolvePageComponent(
            `./Pages/${name}.jsx`,
            import.meta.glob("./Pages/**/*.jsx")
        );
        return page.default || page;
    },
    setup({ el, App, props }) {
        const root = createRoot(el);
        root.render(
            <App {...props} />
        );
    },

});

Please or to participate in this conversation.