atryknaav's avatar

Uncaught (in promise) TypeError: Cannot read properties of null (reading 'dataset') with Inertia and Typescript

I'm trying to deploy my test project for a company on Heroku. I had a bunch of problems with it, and I fixed them, but the current one still persists and there's nothing that helps me on the web.

My site works fine with localhost, but everything I get on the Heroku version is a white screen with @routes @livewireStyles @inertiaHead @inertia as the only text content on it. In the console, I get this stuff:

Uncaught (in promise) TypeError: Cannot read properties of null (reading 'dataset') at $E (app-DUYZ23nC.js:125:1381) at app-DUYZ23nC.js:125:1912

I tried adding @vite('resources/js/app.tsx') to the main blade view both in the header and body after @inertia / @inertiaHead, but nothing worked.

This is the blade file now:

    <title inertia>{{ config('app.name', 'Laravel') }}</title>

    <!-- Fonts -->
    <link rel="preconnect" href="https://fonts.bunny.net">
    <link href="https://fonts.bunny.net/css?family=figtree:400,500,600&display=swap" rel="stylesheet" />

    <!-- Scripts -->
    @routes
    @viteReactRefresh
    @livewireStyles
    @inertiaHead
    @vite('resources/js/app.tsx')
    
</head>
<body class="font-sans antialiased">
    @inertia

</body>

The previous errors I had are:

1.Mix manifest not found at: /app/public/mix-manifest.json

It was fixed by adding @vite('resources/js/app.tsx') to the blade file

2.Mixed content issue- Content must be served as HTTPS

Fixed by changing the .env APP_URL

Any suggestions how to fix the Inertia issue?

0 likes
5 replies
gych's avatar

For what are you using @viteReactRefresh and @livewireStyles ?

In your head try to put @inertiaHead under @vite('resources/js/app.tsx')

    @routes
    @vite('resources/js/app.tsx')
 	@inertiaHead
gych's avatar

@atryknaav Ah ye @viteReactRefresh is because you're using Inertia with React but I don't think you need @livewireStyles since that is for a Laravel Livewire project not Laravel with Inertia.

You can leave @viteReactRefresh in the head under @routes

    @routes
    @viteReactRefresh
    @vite('resources/js/app.tsx')
	@inertiaHead

Which steps did you exactly take when deploying your app to heroku? Have you followed a guide?

atryknaav's avatar

@gych Yes, I followed the steps that Heroku provides you with, when you press 'Create a new project'. It tells you to get the CLI and gives a bunch of commands

Please or to participate in this conversation.