cómo va? Los molesto con un inconveniente que estoy teniendo con un proyecto en ReactJs.
Me figura el error TypeError: Cannot read properties of undefined (reading 'map'.
Mi código es éste:
import { Component } from "react";
const styles = {
DetallesCarro:{
backgroundColor: '#fff',
position: 'absolute',
marginTop: 30,
boxShadow: '1px 5px 5px rgb(0,0,0,0.3)',
borderRadius:'5px',
width:'300px',
right:50,
}
}
class DetallesCarro extends Component {
render(){
const { carro } = this.props
console.log(carro)
return (
<div style={styles.DetallesCarro}>
<ul>
{carro.map(x =>
<li key={x.name}>{x.name}</li>
)}
</ul>
</div>
)
}
}
export default DetallesCarro
Desde ya, muchísimas gracias!
carro
desde el componente padre deDetallesCarro
viaprops
. ¿Puedes agregar el componente padre?