I've searched other posts but couldn't quite find I was looking for. I am looping through data from a sanity api but I want to limit it to just the first 4 items returned. What would be the best way to achieve this? Here is the code in question
 {mappedPosts && mappedPosts && mappedPosts.map ( (post) => (
                    <Col className="mapped-posts" style={redLine} xs="12" lg="4">
                        <div style={imageContainerStyle} onClick={() => router.push(`/logos/${post.slug.current}`)} key={post.index} >
                                <img
                                    src={post.mainImage}
                                alt={post.title}
                                style={imgStyle}
                                layout="fill" />
                            <h3 style={titleStyle}>{post.title}</h3>
                            </div>
                    </Col>
                    )) }   
Can I do something in the loop like:
{mappedPosts && mappedPosts.length < 4 && mappedPosts.map ( (post) => (
Or is there a better way to control how much data is returned with the map function?
 
    