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

110
Visualizações
Filter array and then map through filtered results

I have an array that I want to use as a filter:

export const WHITE_LISTED_CONTRACTS = [
  "0xcfc7b452a470e5533a1fe51ec6fed0596356c80f", // test
  "0x8a6bf00078d5776940c1707cd681afed0c5b0ff2", // test
];

Now, I have an array of tokens that I want to filter - only the whitelisted token.token_address should render:

{tokens.map((token, index) => {
  WHITE_LISTED_CONTRACTS.filter((whitelist) => {
    if (whitelist === token.token_address) {
      return (
        <Component
          token={token}
        />
      }
    });

Any idea what I'm doing wrong?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

you are iterating (filtering) the Whitelist for every token in your array,

Array.includes is the way to go here

{tokens.map((token, index) => {
  if(WHITE_LISTED_CONTRACTS.includes(token.token_address) {
    ...
   }
    }
 }
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