Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

454
Vistas
Issue with react component and gatsby JS

I am trying to create a portfolio website using Gatsby js and I am trying to use the card component from the gatsby-plugin-material-ui package. I have the card in a separate file in my components folder and I export it for use in my actual project page file. When I load up the website on localhost everything loads up fine except for when I hit the project button to navigate to the project page. Once I try to access the page I get this error

Error in function createFiberFromTypeAndProps in ./node_modules/react-dom/cjs/react-dom.development.js:25058

Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports. Check the render method of Cards.

Here is the code where I create and export the component

import * as React from "react"
import Card from 'gatsby-plugin-material-ui';
import CardContent from 'gatsby-plugin-material-ui';
import CardMedia from 'gatsby-plugin-material-ui';
import Typography from 'gatsby-plugin-material-ui';
import { CardActionArea } from 'gatsby-plugin-material-ui'

const Cards = () => {

    return (
        <div className="cardsTest">
            <Card sx={{ maxWidth: 345 }}>
                <CardActionArea>
                    <CardMedia
                        component="img"
                        height="140"
                        image="../images/space.jpg"
                        alt="Gagan Toronto"
                    /> 
                        <CardContent>
                            <Typography gutterBottom variant="h5" component="div">
                                Space Card
                            </Typography>
                            <Typography variant="body2" color="text.secondary">
                                This is just a placeholder card 
                            </Typography>
                        </CardContent>
                </CardActionArea>
            </Card>    
         </div>
    )

}

export default Cards


and here is the code where I import the component to use for my project page

import * as React from "react"

//components used across site
import Header from "../components/header"
import Cards from "../components/Cards"

const ProjectPage = () => (
    <div>
    <Header />
    <Cards />
    </div>
  )

export default ProjectPage;

I feel like its a problem with how I am exporting the component but I am not sure what it is, any help would be greatly appreciated :)

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I feel like its a problem with how I am exporting the component but I am not sure what it is, any help would be greatly appreciated :)

Indeed, it seems that some of your imports of Cards component are wrong. I assume that the one that is causing the issue is CardActionArea but it would be nice if you can detect which one is by commenting them all and importing one by one.

I'd try importing like:

import CardActionArea from 'gatsby-plugin-material-ui'
about 4 years 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 vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda