before adding the map function i was getting the state

after adding map function i get.
I am not able to pinpoint the location of the problem.saw many posts on stackoverflow but none solved my probem
import React,{Fragment,useEffect} from 'react'
import PropTypes from 'prop-types'
import PostItem from './PostItem'
import {connect} from 'react-redux'
import {getPosts} from '../../actions/post'
import Spinner from '../layout/spinner'
const Posts = ({ getPosts, post: { posts, loading } })=>{
useEffect(()=>{
getPosts();
},[getPosts])
return loading ?<Spinner/>:(
<Fragment>
<h1 className="large text-primary">Posts</h1>
<p className="lead">
<i className="fas fa-user"></i>Welcome to the community
</p>
{/* PostForm*/}
<div className="posts">
{
posts.map((post)=>{
return <PostItem key={post._id} post={post} />
})
}
</div>
</Fragment>
)
}
Posts.propTypes={
getPosts:PropTypes.func.isRequired,
post:PropTypes.object.isRequired,
}
const mapStateToProps=state=>({
post:state.post
})
export default connect(mapStateToProps,{getPosts})(Posts)

