hi
why I am getting this error.
TypeError: Cannot read property 'map' of undefined
Contacts
C:/Users/Awais Hassan/Downloads/contactmanager/TASK/src/components/contacts/Contacts.js:18
any help
Code
import React, { useEffect } from "react";
import { connect } from "react-redux";
import Contact from "./Contact";
import PropTypes from "prop-types";
import { getContacts } from "../../actions/contactActions";
function Contacts() {
useEffect(() => {
getContacts();
});
const { contacts } = getContacts();
return (
<>
<h1 className='display-4 mb-2'>
<span className='text-danger'>Contact</span> List
</h1>
{contacts.map((contact) => (
<Contact key={contact.id} contact={contact} />
))}
</>
);
}
const mapStateToProps = (state) => ({
contacts: state.contact.contacts,
});
export default connect(
mapStateToProps,
{ getContacts }
)(Contacts);