inertia-laravel icon indicating copy to clipboard operation
inertia-laravel copied to clipboard

CreateInertiaApp loads twice

Open FlorinCiocirlan opened this issue 2 years ago • 3 comments

Hi,

After we've setup our laravel + inertia app we found out that CreateInertiaApp() runs twice.

//app.js

import { createApp, h } from "vue";
import { createInertiaApp } from "@inertiajs/inertia-vue3";
import DefaultLayout from "../../views/layouts/default";
import { createPinia } from "pinia";
import { importComponent } from "./import-component.js";
import { ZiggyVue } from "ziggy";
import { Ziggy } from "../../js/ziggy";
import { InertiaProgress } from "@inertiajs/progress";

InertiaProgress.init();
createInertiaApp({
  resolve: (name) => {
    console.log("123");
    const component = importComponent(name);

    // Set default layout if no layout specified on component
    component.default.layout ??= DefaultLayout;
    return component;
  },
  setup({ el, App, props, plugin }) {
    const pinia = createPinia();
    const app = createApp({ render: () => h(App, props) })
      .use(plugin)
      .use(pinia)
      .mixin({ methods: { route: window.route } })
      .use(ZiggyVue, Ziggy);

    // added ziggy route helper
    // shows laravel routes in vue
    app.config.globalProperties.$auth = props.initialPage.props.auth;
    app.mount(el);
  },
});

//webpack.mix.js

mix
  .js("resources/assets/js/app.js", "public/js")
  .sass("resources/assets/sass/app.scss", "public/css")
  .webpackConfig(aliasesConfig)
  .sourceMaps()
  .vue({ version: 3 })
  .ziggy()
  .version();
Screen Shot 2022-07-05 at 7 22 42 PM

Can you guys help us ?

FlorinCiocirlan avatar Jul 05 '22 16:07 FlorinCiocirlan

Kind reminder @reinink

FlorinCiocirlan avatar Jul 06 '22 13:07 FlorinCiocirlan

Same happening with me on react, where components are being rendered twice.

usmanvaince avatar Sep 27 '22 06:09 usmanvaince

Same here... any ideas?

timavo avatar Sep 29 '22 16:09 timavo

See https://github.com/inertiajs/inertia/issues/1091 and https://github.com/inertiajs/inertia/pull/1608

jessarcher avatar Sep 08 '23 01:09 jessarcher

Alright @jessarcher, we can see that 1 PR (which is closed) and 1 issue (also closed for no apparent reason) that you linked here. What should we do next? "completed" what?

the-turk avatar Mar 25 '24 15:03 the-turk