Corrected version:
You are causing an infinite loop with useEffect in this way because the component takes "messages" as a prop. By doing so, you are making a server call and updating that exact prop every time the component is re-rendered. I have never actually tried using a skeleton with inertia, but since all the data is returned by the server with the page, I don't see why you would need it. The component doesn't really need to fetch anything since the data is already there the first time. lazy loading is usually used to refetch only the data that is needed. However, in this case, all the data is included in the initial request. You could consider listening for router events and perhaps set up a skeleton there. You can find more information about events in Inertia.js at this link: https://inertiajs.com/events. For example, in one of these events, you can check the loading state and maybe do something to show the skeleton.
router.on('progress', (event) => {
this.form.progress = event.detail.progress.percentage
})