Skip to content
This repository has been archived by the owner on Jan 12, 2023. It is now read-only.

app.js name variable undefined #3

Open
RalfHei opened this issue Sep 16, 2021 · 0 comments
Open

app.js name variable undefined #3

RalfHei opened this issue Sep 16, 2021 · 0 comments

Comments

@RalfHei
Copy link

RalfHei commented Sep 16, 2021

Problem description:

const app = createApp({
    render: () =>
        h(App, {
            initialPage: JSON.parse(el.dataset.page),
            resolveComponent: name => pages[`./Pages/${name}.vue`].default
        }),
});

Error:

Cannot read properties of undefined (reading 'default')

I did some digging and found that the issue comes from InertiaStatamic.php

public function handle(Request $request, Closure $next)
    {
        $page = app(FrontendController::class)->index($request);
      
        if ($page->augmentedValue('template') === 'app' && ($page instanceof Page || $page instanceof Entry)) {
            return Inertia::render(
                $this->buildComponentPath($page),
                $this->buildProps($page)
            );
        }

        return $next($request);
    }

$page->augmentedValue('template') === 'app' => Always returns false

Possible fix

Got it working by adding raw()

$page->augmentedValue('template')->raw() === 'app' => Returns true if app template exists.

Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant