Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

125
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda