question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

500 - Function called outside component initialization

See original GitHub issue

I am trying to use this library in sveltekit with vitejs. Everthing works fine, but when i restart the dev server, i get this error:

500
Function called outside component initialization

Error: Function called outside component initialization
    at get_current_component (/path/to/project/node_modules/.pnpm/svelte-use-form@2.0.1/node_modules/svelte-use-form/dist/index.umd.js:118:19)

What could be the reason that I get this error? Can this be solved? I have seen that this error has also already occurred in Sapper. Maybe i should use svelte for my frontend after all 😄

I use the library in my component like this:

<script>
import { useForm } from 'svelte-use-form'

const form = useForm()
</script>

or do i need to wrapp it in a onMount function?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
niklasgrewecommented, Mar 11, 2021

i created a small repo: https://github.com/niklasgrewe/svelte-use-form-500-error i tested the library svelte-hero-icons and i don’t get any errors on it

1reaction
noahsalvicommented, Mar 16, 2021

Im still looking for a solution but for now adding

optimizeDeps: {
        exclude: ["svelte-use-form"],
    },

to your vite.config.js fixes it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Function called outside component initialization - Stack Overflow
i wanna to recall the onMount in my Svelte app by clicking some button, but i got this error. Any idea would be...
Read more >
Function called outside component initialization #592 - GitHub
I'm getting a Function called outside component initialization error from a sapper v0.26.0-alpha.10 project. A component is being loaded ...
Read more >
How to fix "Function called outside component initialization ...
Recently, a sapper-based project went over the limit for the size of the built image sent to the cloud platform we were using....
Read more >
Svelte - Function called outside component initialization from ...
Svelte - Function called outside component initialization from brand new SvelteKit installation. Hi there,. I have got a very weird behaviour ...
Read more >
8 Lifecycle functions - Svelte and Sapper in Action
Call these functions, passing them a function to be called when the event occurs. They must be called during component initialization.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found