@ignaciodev I’m going to take a stab it’s your useEffect callback that has a call to router.reload inside of it…
Aug 8, 2024
5
Level 2
Why does my Inertia page reload infinitely?
import StorefrontLayout from '@/Layouts/Storefront/StorefrontLayout'
import { useEffect, useState } from 'react'
import { router } from '@inertiajs/react'
function Index({ carts, user }) {
useEffect(() => {
console.log('Component mounted')
router.reload({
only: ['user'],
preserveState: true,
preserveScroll: true,
replace: true,
onSuccess: page => { console.log('SUCCESS', page) }
})
}, [])
return <></>
}
Index.layout = page => <StorefrontLayout children={page} />
export default Index
Level 2
I fixed it by wrapping the router.reload inside a setTimeout
1 like
Please or to participate in this conversation.