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

187
Views
TypeError no detectado: data.map no es una función -> error de componente de reacción

Oye, tengo un pequeño problema en mi componente modal. El problema es el siguiente error: TypeError no detectado: meatState.map no es una función ¿Alguna idea de qué podría estar causando esto? Agradezco mucho la ayuda. Y también, meatState es de hecho una matriz.

Modal.js

 import React, { useContext } from "react"; import showModal from "../store/meat-context"; import MeatContext from "../store/meat-context"; import CartItem from "./CartItem"; import styles from "./Modal.module.css"; function Modal() { const modal = useContext(showModal); const { meatState, dispatchMeatState } = useContext(MeatContext); if (!modal.showModal) { return null; } return ( <div className={styles.backdrop}> <div className={styles.modal}> {meatState.map((meat) => { return ( <CartItem name={meat.name} price={meat.price} id={meat.id} description={meat.description} /> ); })} </div> </div> ); } export default Modal;
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Como han dicho otros, meatState no must ser una matriz. podría ser nulo o indefinido. Puede agregar este código donde está el mapa para verificar si este es su problema.

 {meatState !== undefined && meatState.map((meat) => { return ( <CartItem name={meat.name} price={meat.price} id={meat.id} description={meat.description} /> ); })}

o Verifique el estado de la carne con useEffect() en su componente Modal.

 useEffect(() => { console.log(meatState) }, [meatState])
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!