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

102
Views
Cómo cambiar o anular el componente común en React js

Tengo un componente común para el que quiero cambiar su propiedad de color para usarlo en otro lugar.

 const ViewAllIcon = (props) => ( <svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 26 27" {...props} > <path fill="var(--primary)" d="M13 0C5.832 0 0 5.86 0 13.061c0 7.202 5.832 13.062 13 13.062s13-5.86 13-13.062C26 5.86 20.168 0 13 0z" /> <path fill="#FFF" d="M14.764 13.061l-4.437-4.726c-.48-.512-.48-1.344 0-1.856s1.261-.512 1.742 0l5.357 5.708c.454.483.454 1.266 0 1.749l-5.357 5.707c-.48.512-1.261.512-1.742 0-.48-.512-.48-1.343 0-1.855l4.437-4.727z" /> </svg> ); export default ViewAllIcon;

Este es un componente común que tiene un color primario azul y blanco.

 <ViewAllIcon className="ml8" fill="white" />

Lo estoy usando para cambiar el color de relleno a blanco y verde. Este es el resultado final

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

0

Podrías poner los accesorios directamente para llenar el atributo

Algo como esto:

 const ViewAllIcon = (props) => ( <svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 26 27" {...props} > <path fill={props.fill} // <--- UPDATE HERE! d="M13 0C5.832 0 0 5.86 0 13.061c0 7.202 5.832 13.062 13 13.062s13-5.86 13-13.062C26 5.86 20.168 0 13 0z" /> <path fill="#FFF" d="M14.764 13.061l-4.437-4.726c-.48-.512-.48-1.344 0-1.856s1.261-.512 1.742 0l5.357 5.708c.454.483.454 1.266 0 1.749l-5.357 5.707c-.48.512-1.261.512-1.742 0-.48-.512-.48-1.343 0-1.855l4.437-4.727z" /> </svg> ); export default ViewAllIcon;

Ejemplo de trabajo:

Editar sol-antiguo-r5zc1

about 4 years ago · Juan Pablo Isaza Report

0

cambie el valor de relleno a "color actual" y luego pase la variable de color al componente.

 ViewAllIcon({ color: 'var(--primary)' }) or <ViewAllIcon color={'var(--primary)'} /> const ViewAllIcon = (props) => ( <svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 26 27" {...props} > <path fill="currentColor" d="M13 0C5.832 0 0 5.86 0 13.061c0 7.202 5.832 13.062 13 13.062s13-5.86 13-13.062C26 5.86 20.168 0 13 0z" /> <path fill="currentColor" d="M14.764 13.061l-4.437-4.726c-.48-.512-.48-1.344 0-1.856s1.261-.512 1.742 0l5.357 5.708c.454.483.454 1.266 0 1.749l-5.357 5.707c-.48.512-1.261.512-1.742 0-.48-.512-.48-1.343 0-1.855l4.437-4.727z" /> </svg> ); export default ViewAllIcon;
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!