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

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.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 5
  • Comments: 16 (4 by maintainers)

Most upvoted comments

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

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 })

Sorry to hear that. Understandable.

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