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

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

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 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