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

319
Views
In React-Native, how can I choose an assets folder instead of another one based on my environment file?

I'm building white label apps.

I have an assets folder that contains one images folder and one fonts folder for each brands.

Like so :

assets/
   brand1/
      fonts/
      images/
        img1.png
        img2.png
        img3.png
   brand2/
      fonts/
      images/
        img1.png
        img2.png
        img3.png
src/

My idea would be to have an index.js at the root of the assets folder where I'd be able to export the relevant set of folders based on my environment file.

Though I'm not sure how to achieve that.

Any hint ?

(My concern is that I don't want to have the environment conditioning in each of my components)

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Let us assume that you have two environments;

.env.brand1 NAME=BRAND1 .env.brand2 NAME=BRAND2

create an index.js file, it's code should look something like this;

const images = {
    BRAND1: {
        logo: require('./brand1/brand1Logo.jpeg')
    },
    BRAND2: {
        logo: require('./brand2/brand2Logo.jpeg')
    }

}

export default images;

You can now use image in any file like this;

... other imports
import images from '#assets/index'

export default function () {
    
    ...other code 

    <Image source={images[Config.NAME].logo} />

}

Folder structure

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!