vuelidate icon indicating copy to clipboard operation
vuelidate copied to clipboard

Error: Maximum recursive updates exceeded. - with nested useVuelidate usage

Open etay2000 opened this issue 4 years ago • 7 comments

When using nested validation, and a parent that displays validation errors in it's template, any changes to the nested component causing a hot reload trigger a 'Maximum recursive updates exceeded error'. Removing the reference to validation.$errors in the parent template resolves the error.

<!-- Parent -->
<template>
  <span>Parent errors: {{ validation.$errors }}</span> 
  <Nested/>
</template>
<script lang="ts">
export default defineComponent({
  components: {
    Nested
  },
  setup() {
    const rules: any = {};
    const validation: Ref<Validation> = useVuelidate(rules, {});
    console.log('Hot Reload: Parent');
    return {
      validation
    };
  }
})
</script>

<!-- Nested -->
<template>
  <span>Nested</span>
</template>
<script lang="ts">
export default defineComponent({
  setup() {
    const rules: any = {};
    const validation: Ref<Validation> = useVuelidate(rules, {});
    console.log('Hot Reload: Nested:::');
    return {};
  }
})
</script>

Update the console log text to trigger a hot-reload which will trigger the maximum recursion error.

etay2000 avatar Dec 09 '20 18:12 etay2000

This is something we are working on. However, you could help us a lot by providing a failing test for that specific case!

shentao avatar Dec 09 '20 19:12 shentao

I'd love to help, but I've already lost a fair amount of time hunting this down. It should be pretty easy to duplicate using the minimal code above.

etay2000 avatar Dec 09 '20 19:12 etay2000

Sorry to hear that. Understandable.

shentao avatar Dec 09 '20 19:12 shentao

I'm also facing this maximum recursive updates issue with child components, but in a slightly different scenario, using custom validation methods. Have you made any progress on this? I've tried to create a codesandbox.io project that reproduces the issue, but I can't seem to get vue3 and vuelidate working together in codesandbox. But I do have a minimal version that I can share?

ajdvoynos avatar Jan 27 '21 23:01 ajdvoynos

Could you guys try with the latest Vuelidate version?

dobromir-hristov avatar Feb 04 '21 21:02 dobromir-hristov

Still having this problem in 2.0.0-alpha.10 😿

lamka02sk avatar Feb 10 '21 00:02 lamka02sk

For anyone seeking fast although not proper solution, use $scope property in useVuelidate function: https://vuelidate-next.netlify.app/advanced_usage.html#scope-property

useVuelidate(rules, data, { $scope: false })

lamka02sk avatar Feb 10 '21 00:02 lamka02sk

I am facing the same problem. Parent component and array of child components with several fields with validators. When hot reload I get recursion. I will try to provide example in the following days.

darkopetreski avatar Oct 23 '22 20:10 darkopetreski

Do you have any updates on this issue?

emanuelradu avatar Jan 05 '23 15:01 emanuelradu

It's been nearly 3 years now, any updates or workarounds ?

abcirta avatar Jul 28 '23 08:07 abcirta

@arslan-bz could you provide a repo with minimal reproduction steps?

shentao avatar Jul 28 '23 08:07 shentao

Hi, any updates here? I'm experiencing the same very frustrating issue.

joshuagraber avatar Nov 13 '23 19:11 joshuagraber

Hello, same on my end, very annoying issue, please help. @shentao @dobromir-hristov

nerminjukan avatar Nov 16 '23 23:11 nerminjukan

I have this same problem but using useField.

  import { useField } from 'vee-validate';

  defineOptions({
    inheritAttrs: false,
  });

  const props = defineProps<{
    autocomplete?:
      | 'current-password'
      | 'email'
      | 'family-name'
      | 'given-name'
      | 'new-password'
      | 'off'
      | 'on'
      | 'username';
    disabled?: boolean;
    hasError?: boolean;
    hasWarning?: boolean;
    hint?: string;
    iconLeft?: `lucide:${string}`;
    iconRight?: `lucide:${string}`;
    label: string;
    name: string;
    placeholder?: string;
    readonly?: boolean;
    type: 'email' | 'password' | 'search' | 'tel' | 'text' | 'url';
  }>();

  const isFocused = ref(false);
  const isShowPassword = ref(false);

  const { errorMessage, errors, handleBlur, handleChange, value } = useField(() => props.name);

image

sawa-ko avatar Dec 11 '23 00:12 sawa-ko