this.resolveComponent is not a function

I’m building an application with Laravel + React. I use Inertia.js to combine the two. The project was generated through Vite.js, which is also used.

I now have built a table, which is responsive so I can make changes to it and these changes should be saved to the database when I click save. This works, however, I keep getting the error this.resolveComponent is not a function whenever the table should be re-rendered. It seems that I cannot re-render components for some reason and I tried everything I can think of.

app.jsx

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>import './bootstrap';
import '../css/app.css';
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 || 'Laravel';
createInertiaApp({
title: (title) => `${title} - ${appName}`,
resolve: (name) => resolvePageComponent(`./Pages/${name}.jsx`, import.meta.glob('./Pages/**/*.jsx')),
setup({ el, App, props }) {
const root = createRoot(el);
root.render(<App {...props} />);
},
progress: {
color: '#4B5563',
},
});
</code>
<code>import './bootstrap'; import '../css/app.css'; 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 || 'Laravel'; createInertiaApp({ title: (title) => `${title} - ${appName}`, resolve: (name) => resolvePageComponent(`./Pages/${name}.jsx`, import.meta.glob('./Pages/**/*.jsx')), setup({ el, App, props }) { const root = createRoot(el); root.render(<App {...props} />); }, progress: { color: '#4B5563', }, }); </code>
import './bootstrap';
import '../css/app.css';

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 || 'Laravel';
createInertiaApp({
    title: (title) => `${title} - ${appName}`,
    resolve: (name) => resolvePageComponent(`./Pages/${name}.jsx`, import.meta.glob('./Pages/**/*.jsx')),
    setup({ el, App, props }) {
        const root = createRoot(el);

        root.render(<App {...props} />);
    },
    progress: {
        color: '#4B5563',
    },
});

Can you guys give me any advice? I cannot seem to fix this and there is not much online about this issue either.

Alright, I don’t know what I did wrong, but I decided to create a clean Laravel/React/InertiaJS (+ Laravel Breeze for the auth stuff) stack using Vite and then moved all my code over to the new project. I suppose something was wrong with my project, as of now it works perfectly.

If anyone ever wants to try the same solution, here are the commands I used to build a new project (these instructions were generated using ChatGPT):

  1. Install Laravel:
    Ensure you have Composer installed, then create a new Laravel project.

    Plain text
    Copy to clipboard
    Open code in new window
    EnlighterJS 3 Syntax Highlighter
    <code>composer create-project --prefer-dist laravel/laravel myshop
    cd myshop
    </code>
    <code>composer create-project --prefer-dist laravel/laravel myshop cd myshop </code>
    composer create-project --prefer-dist laravel/laravel myshop
    cd myshop
    

2. Install Laravel Breeze

  1. Install Laravel Breeze:
    Laravel Breeze provides a minimal implementation of all of Laravel’s authentication features using Blade. Since we want to use React with InertiaJS, we need the React preset.

    Plain text
    Copy to clipboard
    Open code in new window
    EnlighterJS 3 Syntax Highlighter
    <code>composer require laravel/breeze --dev
    php artisan breeze:install react
    </code>
    <code>composer require laravel/breeze --dev php artisan breeze:install react </code>
    composer require laravel/breeze --dev
    php artisan breeze:install react
    
  2. Install & Build Frontend Assets:

    Plain text
    Copy to clipboard
    Open code in new window
    EnlighterJS 3 Syntax Highlighter
    <code>npm install && npm run dev
    </code>
    <code>npm install && npm run dev </code>
    npm install && npm run dev
    

3. Install Laravel InertiaJS

  1. Install InertiaJS Server-side:

    Plain text
    Copy to clipboard
    Open code in new window
    EnlighterJS 3 Syntax Highlighter
    <code>composer require inertiajs/inertia-laravel
    </code>
    <code>composer require inertiajs/inertia-laravel </code>
    composer require inertiajs/inertia-laravel
    
  2. Install Inertia Middleware:

    After installation, register the middleware in your AppHttpKernel.php file:

    Plain text
    Copy to clipboard
    Open code in new window
    EnlighterJS 3 Syntax Highlighter
    <code>'web' => [
    // Other middleware...
    AppHttpMiddlewareHandleInertiaRequests::class,
    ],
    </code>
    <code>'web' => [ // Other middleware... AppHttpMiddlewareHandleInertiaRequests::class, ], </code>
    'web' => [
        // Other middleware...
        AppHttpMiddlewareHandleInertiaRequests::class,
    ],
    

4. Setup Vite with React and InertiaJS

  1. Install Client-side Dependencies with Vite:

    Plain text
    Copy to clipboard
    Open code in new window
    EnlighterJS 3 Syntax Highlighter
    <code>npm install @inertiajs/react @vitejs/plugin-react vite axios
    </code>
    <code>npm install @inertiajs/react @vitejs/plugin-react vite axios </code>
    npm install @inertiajs/react @vitejs/plugin-react vite axios
    
  2. Configure Vite:
    Replace contents of your vite.config.js with:

    Plain text
    Copy to clipboard
    Open code in new window
    EnlighterJS 3 Syntax Highlighter
    <code>import { defineConfig } from 'vite';
    import react from '@vitejs/plugin-react';
    import path from 'path';
    export default defineConfig({
    plugins: [react()],
    resolve: {
    alias: {
    '@': path.resolve(__dirname, 'resources/js'),
    },
    },
    server: {
    watch: {
    usePolling: true,
    },
    },
    });
    </code>
    <code>import { defineConfig } from 'vite'; import react from '@vitejs/plugin-react'; import path from 'path'; export default defineConfig({ plugins: [react()], resolve: { alias: { '@': path.resolve(__dirname, 'resources/js'), }, }, server: { watch: { usePolling: true, }, }, }); </code>
    import { defineConfig } from 'vite';
    import react from '@vitejs/plugin-react';
    import path from 'path';
    
    export default defineConfig({
        plugins: [react()],
        resolve: {
            alias: {
                '@': path.resolve(__dirname, 'resources/js'),
            },
        },
        server: {
            watch: {
                usePolling: true,
            },
        },
    });
    

5. Setup Inertia React Components

  1. Update Resources JS Structure:
    Create folders for your React components if they don’t already exist:

    Plain text
    Copy to clipboard
    Open code in new window
    EnlighterJS 3 Syntax Highlighter
    <code>mkdir -p resources/js/Pages resources/js/Components
    touch resources/js/Pages/Dashboard.jsx resources/js/Pages/Login.jsx
    </code>
    <code>mkdir -p resources/js/Pages resources/js/Components touch resources/js/Pages/Dashboard.jsx resources/js/Pages/Login.jsx </code>
    mkdir -p resources/js/Pages resources/js/Components
    touch resources/js/Pages/Dashboard.jsx resources/js/Pages/Login.jsx
    
  2. Create an app.jsx entry point:
    In resources/js, create app.jsx:

    Plain text
    Copy to clipboard
    Open code in new window
    EnlighterJS 3 Syntax Highlighter
    <code>import React from 'react';
    import { render } from 'react-dom';
    import { createInertiaApp } from '@inertiajs/react';
    import { InertiaProgress } from '@inertiajs/progress';
    import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers';
    createInertiaApp({
    resolve: (name) => resolvePageComponent(
    `./Pages/${name}.jsx`,
    import.meta.glob('./Pages/**/*.jsx')
    ),
    setup({ el, App, props }) {
    render(<App {...props} />, el);
    },
    });
    InertiaProgress.init();
    </code>
    <code>import React from 'react'; import { render } from 'react-dom'; import { createInertiaApp } from '@inertiajs/react'; import { InertiaProgress } from '@inertiajs/progress'; import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers'; createInertiaApp({ resolve: (name) => resolvePageComponent( `./Pages/${name}.jsx`, import.meta.glob('./Pages/**/*.jsx') ), setup({ el, App, props }) { render(<App {...props} />, el); }, }); InertiaProgress.init(); </code>
    import React from 'react';
    import { render } from 'react-dom';
    import { createInertiaApp } from '@inertiajs/react';
    import { InertiaProgress } from '@inertiajs/progress';
    import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers';
    
    createInertiaApp({
        resolve: (name) => resolvePageComponent(
            `./Pages/${name}.jsx`,
            import.meta.glob('./Pages/**/*.jsx')
        ),
        setup({ el, App, props }) {
            render(<App {...props} />, el);
        },
    });
    
    InertiaProgress.init();
    

6. Update Laravel Blade View

  1. Add Main Inertia View:
    Update resources/views/app.blade.php or create it:

    Plain text
    Copy to clipboard
    Open code in new window
    EnlighterJS 3 Syntax Highlighter
    <code><!DOCTYPE html>
    <html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
    <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title inertia>{{ config('app.name', 'Laravel') }}</title>
    @viteReactRefresh
    @vite('resources/js/app.jsx')
    @inertiaHead
    </head>
    <body class="font-sans antialiased">
    @inertia
    </body>
    </html>
    </code>
    <code><!DOCTYPE html> <html lang="{{ str_replace('_', '-', app()->getLocale()) }}"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title inertia>{{ config('app.name', 'Laravel') }}</title> @viteReactRefresh @vite('resources/js/app.jsx') @inertiaHead </head> <body class="font-sans antialiased"> @inertia </body> </html> </code>
    <!DOCTYPE html>
    <html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
        <head>
            <meta charset="utf-8">
            <meta name="viewport" content="width=device-width, initial-scale=1">
            <title inertia>{{ config('app.name', 'Laravel') }}</title>
            @viteReactRefresh
            @vite('resources/js/app.jsx')
            @inertiaHead
        </head>
        <body class="font-sans antialiased">
            @inertia
        </body>
    </html>
    

7. Run Migrations and Build Project

  1. Run Migrations:

    Plain text
    Copy to clipboard
    Open code in new window
    EnlighterJS 3 Syntax Highlighter
    <code>php artisan migrate
    </code>
    <code>php artisan migrate </code>
    php artisan migrate
    
  2. Run the Development Server:

    Plain text
    Copy to clipboard
    Open code in new window
    EnlighterJS 3 Syntax Highlighter
    <code>php artisan serve
    npm run dev
    </code>
    <code>php artisan serve npm run dev </code>
    php artisan serve
    npm run dev
    

8. Setup Inertia Links in Laravel Breeze

  1. Update Auth Components:
    Ensure that your Breeze auth components use Inertia for navigation. You can wrap form submissions in a useForm hook from Inertia, for instance. For example, in your Login.jsx:

    Plain text
    Copy to clipboard
    Open code in new window
    EnlighterJS 3 Syntax Highlighter
    <code>import React from 'react';
    import { useForm } from '@inertiajs/react';
    export default function Login() {
    const { data, setData, post } = useForm({
    email: '',
    password: '',
    remember: false,
    });
    const submit = (e) => {
    e.preventDefault();
    post(route('login'));
    };
    return (
    <form onSubmit={submit}>
    {/* Your form fields */}
    </form>
    );
    }
    </code>
    <code>import React from 'react'; import { useForm } from '@inertiajs/react'; export default function Login() { const { data, setData, post } = useForm({ email: '', password: '', remember: false, }); const submit = (e) => { e.preventDefault(); post(route('login')); }; return ( <form onSubmit={submit}> {/* Your form fields */} </form> ); } </code>
    import React from 'react';
    import { useForm } from '@inertiajs/react';
    
    export default function Login() {
        const { data, setData, post } = useForm({
            email: '',
            password: '',
            remember: false,
        });
    
        const submit = (e) => {
            e.preventDefault();
            post(route('login'));
        };
    
        return (
            <form onSubmit={submit}>
                {/* Your form fields */}
            </form>
        );
    }
    
    

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật