-4

I have this array

 {product.images.map((img, index) => (
                        <img key={index} src={img.url}
                        
                         />
                    ))}

as I only wanna render first 5 photos.. How to get the first 5 photos from an array ??

2

1 Answer 1

2
{ product.images.slice(0, 5).map((img, index) => (
    <img key={index} src={img.url}/>
)) }
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.