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

325
Visualizações
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 Respostas
Responde à pergunta

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