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

220
Vistas
Trying to style data rendered from my DB with styled components and getting Invalid hook call error

So I'm trying to style data from my rendered react components and have the following Issue.

I think my issue is "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:" but I'm unable to fix this.

import {useEffect, useState} from "react";
import React from 'react'
import styled from 'styled-components';
import ButtonUnstyled from '@mui/base/ButtonUnstyled';
// import { Title } from '../MainElements';
const API_BASE = "http://localhost:3001";


export const RocketCard = () => {
  const [rockets, setRockets] = useState([{
    name: '',
    id: ''
  }])

  useEffect(() => {
      fetch(API_BASE + '/rockets')
        .then(res => res.json())
        .then(data => setRockets(data))
        .catch((err) => console.error("Error: ", err));
    },[])


  return ( <div className="container">
  
    <Title>Test</Title>
    {rockets.map(rocket =>
    <div className="rocket" key={rocket._id} >
      <h1>{rocket.name}</h1>
    </div>
    )}
  </div>
);

}

const Title = styled.h1`
display: flex;
align-items: center;
line-height: 1.2;
`;

Console Errors

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