Inertia resolves the page twice at first load

See original GitHub issue

Versions:

  • @inertiajs/inertia version: 0.11.0
  • @inertiajs/inertia-vue version:0.8.0

Describe the problem:

When open the page the first time, the code inside resolve function will execute twice.

Steps to reproduce:

createInertiaApp({
    resolve: (name) => {
        const page = require(`./Pages/${name}`).default
        page.layout = page.layout || Layout
        return page
    },
    setup({ el, App, props, plugin }) {
        Vue.use(plugin)
        let vm = new Vue({
            render: h => h(App, props),
        }).$mount(el);
    },
})

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:2
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
reinvanimschootcommented, Sep 23, 2022

I tried to reproduce this issue in a new project using React, Rails and Inertia (bundled with Webpacker).

The project can be found here

Even in a newly built app, with the most recent versions of both Inertia and Inertia-rails, the page, without even providing it with props or using usePage is rendered twice.

The only solution that fixed the issue is to wrap the page function in React.memo. I haven’t tried this in our production app so I don’t know whether or not this results in other problems but at least the render only happens once.

Maybe this is something that Inertia could use under the hood?

0reactions
RationalFragilecommented, Nov 19, 2022

Also facing this same issue. Any ideas how to fix it with vue3?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Partial reloads - Inertia.js
Partial reloads. When making visits to the same page, it's not always necessary to fetch all of the data required for that page...
Read more >
Vue page tries to send request twice. i'm using inertia, Laravel ...
i clicked store and delete one time, but both of request send twice. i had added prevent.default but it seems like not working....
Read more >
Bug: useEffect runs twice on component mount (StrictMode ...
The useEffect callback runs twice for initial render, probably because the component renders twice. After state change the component renders ...
Read more >
Portlet is loaded twice on one page - Forums - Liferay
Hi all, I'm currently facing a problem that the portlet I'm developing is loaded twice if the page is refreshed. My portlet is...
Read more >
FOLDS & DIMENSIONS
Page 1. x. F-1-F. F-1-B. 3 5/8. 4. 2. 3. 3 11/16. 3 11/16. Inside Cover. Fold. Fold ... FOLDS & DIMENSIONS. Fold...
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