0
votes

While using the svelte-forms in sveltekit I am getting the following runtime error even calling the function inside the onMount

funtion called outside component initialisation
1

1 Answers

1
votes

This can be solved by providing validateOnChange option in form function.

<script>
  import { onMount, afterUpdate } from 'svelte';
  import { form } from 'svelte-forms';

  let myForm;

  onMount(() => {
    myForm = form(() => ({}), {
      validateOnChange: false
    });
  });

  afterUpdate(() => {
    myForm.validate();
  });
</script>