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

143
Views
Reaccionar: ¿cuál debería ser el icono de la interfaz de usuario de propType of Material?

Voy a pasar el icono de MUI al componente Test y quiero crear un Protipo para el icono, pero no estoy seguro de cuál debería ser el tipo de propiedad correcto del icono.

Aplicación.js

 import "./styles.css"; import VisibilityIcon from "@material-ui/icons/Visibility"; import Test from "./Test"; export default function App() { return ( <div className="App"> <Test icon={<VisibilityIcon />} /> </div> ); }

Prueba.jsx

 import PropTypes from "prop-types"; function Test(props) { const { icon } = props; return ( <div> Icon: {icon} </div> ); } Test.propTypes = { // icon: ?????? }; export default Test;

https://codesandbox.io/s/intelligent-curie-8mtbw?file=/src/Test.jsx:0-213

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

0

Debería ser un PropTypes.element

 Test.propTypes = { icon: PropTypes.element };

Ejemplo de trabajo:

Editar ferviente-poitras-ubr96

about 4 years ago · Juan Pablo Isaza Report

0

Iría con PropTypes.element aquí si quieres ser específico.

Comprobación de tipos con PropTypes

 Test.propTypes = { icon: PropTypes.element, };
 // A React element. optionalElement: PropTypes.element,

Si desea ser un poco más flexible/general, use PropTypes.node para cualquier cosa que se pueda renderizar.

 // Anything that can be rendered: numbers, strings, elements or an array // (or fragment) containing these types. optionalNode: PropTypes.node,

Editar reaccionar-lo-que-debería-ser-el-proptype-of-material-ui-icon

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!