inertia: v-if causing "Unhandled error during execution of scheduler flush" after form.post
Versions:
@inertiajs/inertiaversion: 0.8.7@inertiajs/inertia-vue3version: 0.3.14vueversion 3.0.11
Describe the problem:
When posting a form that updates a prop that is being used in a v-if something goes wrong.
Getting a warning with:
[Vue warn]: Unhandled error during execution of scheduler flush. This is likely a Vue internals bug.
Followed by an error:
TypeError: can’t access property “insertBefore”, parent is null
Steps to reproduce:
I’m using Laravel and Vue3. Here’s a component (Route/Index):
<template>
<!-- here I have a layout component -->
<form @submit.prevent="form.post(route('route.post'))">
<button>Create thing</button>
</form>
<div v-if="someProp">
{{ someProp }}
</div>
<!-- end of layout component -->
</template>
<script>
import { useForm } from '@inertiajs/inertia-vue3'
export default {
props: {
someProp: String
}
setup () {
const form = useForm()
return { form }
},
}
</script>
Here’s the laravel controller methods:
public function index()
{
return Inertia::render('Route/Index', [
'someProp' => session()->get('propContent'),
]);
}
public function store()
{
// do stuff
$prop = 'Blabla';
return redirect()->back()->with('propContent', $prop);
}
Workaround
As a workaround I’m adding { preserveState: false } to form.post and it works.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 3
- Comments: 23 (4 by maintainers)
Hey folks, this issue sounds similar to this one: #615
As noted in my comment on that issue, I was able to fix the issue by wrapping by entire page component in an extra
<div>. I have a feeling this issue is related to fragments in Vue 3.Give that a try and let me know?
@reinink I had this exact issue on a new install of Laravel / Jetstream / Inertia.
preserveState: falseis causing a full component render which is not desired in my case. Is there any other solution for this?I’m trying to display the validation errors in v-for and after $inertia.post call but getting the
TypeError: can't access property "insertBefore", parent is nullerror.