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

202
Visualizações
Best Practice on Building an Icon Selection Component

Well, I'm working on a multi-repo project where I'm dealing with the following problem in the implementation of my project's component library regarding icon selection.

I prototyped my icons according to the project's desire, but the time for implementation has arrived and I don't know how to put them correctly and so I would like to remove this doubt.

Initially I implemented it like this:

import React from 'react';
import * as Icons from 'my-icons-lib';

function Icon(props: any) {
 const IconSettings = {
     Name: props.IconName,
     Color: props.IconColor,
     Height: props.IconHeight,
     Width: props.IconWidth
 }

 const IconSelected = Icons[IconSettings.Name]

return(
 <IconSelected
     {...IconSettings.Color}
     {...IconSettings.Height}
     {...IconSettings.Width}
  />
);
}

export default Icon;

Beside the final project where these components will be used, this one in this case will be used to render my icon according to the value passed by props.IconName which should search an array for the icon I want to use.

And when it gets the answer, it will be used like this in the final repo build:

If so, use phoneIcon to pass in props.IconName.

<PhoneIcon color="#3457f" />

However, when trying to do this, the search that would occur on const IconSelected = Icons[IconSettings.Name] doesn't happen because apparently it can't access the index where the value should be found in this array of my icon library.

It even returns the error of which it is:

Binding element 'IconSettings.Name' implicitly has a type 'any'.ts(7031)

So what should I do so that it can work properly? What is the good practice for this?

about 4 years ago · Juan Pablo Isaza
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