Company logo
  • Empleos
  • Bootcamp
  • Acerca de nosotros
  • Para profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
    • Bootcamp
  • Para empresas
    • Inicio
    • Nuestro proceso
    • Planes
    • Pruebas
    • Nómina
    • Blog
    • Calculadora

0

83
Vistas
How to pass component in React mui menuItem

I imported Report.js component and want to use it in "menuitem", I tried this in button and its working perfectly

 import Reports from 'new-components/Reports/Reports'   //ontop

 <Button> 
    <Reports pid={pid} />          //working
 </Button>

but when i tried this same in "menuitem" than its not working

<MenuItem >
  <Reports pid={pid} />            //not working
</MenuItem>

i also tried with onClick function, although it gives the desired result but also throws a error " Uncaught Error: Expected onClick listener to be a function, instead got a value of object type."

Reports.js

  return (
     <CSVLink {...csvReport}>Export CSV</CSVLink>
     )

7 months ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You could try to pass your Reports element via the component prop of MenuItem:

const YourComponent = () => {
  return <MenuItem component={<Reports pid={pid} />} />;
}

https://mui.com/material-ui/api/menu-item/#props

7 months ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar empleo Planes Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2023 PeakU Inc. All Rights Reserved.