Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

237
Visualizações
Is it guaranteed that Svelte's onMount() is called once in production?

Given that onMount() of Svelte is a lifecycle function, it seems that onMount() is called once for each component.

However, I found that onMount() is called whenever I modify the code in Svelte REPL.

For example, if you modify the code in Svelte MathJax REPL,
and open the inspector of the browser,
you will find several scripts of the same src attribute are added to the DOM.

example image

Does this only happen in REPL, or also in the production version?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

In the REPL everytime you modify the code the component is re-mounted because it has changed and should now show a different component.

In a production app this will not happen because you are not changing the code anymore. It will however be called once per instance of this component:

<Component />
<Component />
<Component />
<Component />

the above code would fire the onMount in Component 4 times because you have 4 instances of it.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda