question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Layout: null ignored on default layout.

See original GitHub issue

Versions:

  • @inertiajs/inertia version: 0.10.1
  • @inertiajs/inertia-vue version: 0.7.2

Describe the problem:

When setting up a default layout the layout: null is ignored as setting.

Steps to reproduce:

Setup a default layout and try to exclude a page from it by using the layout: null setting.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
Vercouterecommented, Jan 26, 2022

@HazJ Dynamic imports return a promise.

See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#dynamic_imports

You can set the default layout once the import has resolved.

resolve: name => {
    return import(`./Pages/${name}.vue`)
    .then(page => {
        page.default.layout = page.default.layout || App;
        return page;
    });
},
3reactions
reininkcommented, Aug 18, 2021

Without any code, this is hard to help with. However, I’m guessing you’re using the example code from the docs for this:

import Layout from './Layout'

createInertiaApp({
  resolve: name => {
    const page = require(`./Pages/${name}`).default
    page.layout = page.layout || Layout
    return page
  },
  // ...
})

Instead of doing that, try this instead:

createInertiaApp({
  resolve: name => {
    const page = require(`./Pages/${name}`).default
    if (page.layout === undefined) {
      page.layout = Layout
    }
    return page
  },
  // ...
})

This will support setting the layout to null, which will disable the default layout. 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Setting Layout to null in _Layout.cshtml - Stack Overflow
In nested layouts , you intentionally use Layout property to define super layout of layout page . By default it is null in...
Read more >
Layout = null vs. ignoring Layout Property in ASP.NET MVC
This is pretty simple , Layout=null , the view does not use any layout and the layout of the page will be the...
Read more >
Layout in ASP.NET Core - Microsoft Learn
Ignoring sections​​ By default, the body and all sections in a content page must all be rendered by the layout page. The Razor...
Read more >
View - Android Developers
Horizontal layout direction of this view is from deduced from the default language script for the locale. int, LAYOUT_DIRECTION_LTR.
Read more >
StackPane (JavaFX 8) - Oracle Help Center
If set, the stackpane will layout the child with the margin space around it. Setting the value to null will remove the constraint....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found