Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

116
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!