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

123
Visualizações
How is this if block being executed in this imported file?

I have an index.js file (entry point in my react app) that imports 2 named exports from another file like so:

import { funcA, funcB } from './myFuncFile

and in myFuncFile I have an if statement at the top like so:

if (process.env.NODE_ENV === "local") {
   // do some stuff
}

this might be a silly question but how is that if statement being called?

I assumed I'd have to import the whole file like:

import * as myFun from './myFuncFile

to get the if block to work? is the mere fact I'm just importing it, causing the if block to execute?

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

0

The simple answer is yes. When the file is imported as a whole, then this line will be triggered when the exported statements are loaded into memory.

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