inertiajs / inertia

Inertia.js lets you quickly build modern single-page React, Vue and Svelte apps using classic server-side routing and controllers.
https://inertiajs.com
MIT License
6.3k stars 423 forks source link

form clearErrors() in computed value throws "Maximum recursive updates exceeded in component" #1815

Closed olehlong closed 6 months ago

olehlong commented 7 months ago

Version:

Describe the problem:

When form.clearErrors() called in a computed value that used, for example, in toggling button disabled state, it throws an error:

"Maximum recursive updates exceeded in component . This means you have a reactive effect that is mutating its own dependencies and thus recursively triggering itself. Possible sources include component template, render function, updated hook or watcher source function."

In production it hangs the page with recursion.

I have no issues with vue 3.4.14, but any newer version gives this error. So it's related to the recent changes in vue reactivity.

Steps to reproduce:

Basic example . It throws the error on start.

shengslogar commented 6 months ago

It's considered an anti-pattern to mutate state inside of a computed property. You've basically made an infinite loop.

https://vuejs.org/guide/essentials/computed.html#getters-should-be-side-effect-free