Dicky Saputra Posted on Nov 23, 2021 • Edited on Mar 28, 2022 Loop an Array JS #javascript #react #programming #beginners Top comments (2) Subscribe Collapse Expand Andrew Bone Andrew Bone Andrew Bone Follow A British web developer, that is passionate about web accessibility. Location Britain, Europe Pronouns He/Him Work Senior Web Developer at bloc-digital Joined Jun 8, 2017 • Nov 23 '21 Dropdown menu Copy link Hide You could make this a bit simpler by using new Array which lets you just say how long you want an array to be. function Loading({ item = 4 }) { return [...new Array(item)].map((_, i) => ( <div key={`skeleton-just-arrived-${i}`} className="px-4 relative card group"> <div className="rounded-xl overflow-hidden card-shadow relative bg-gray-300" style={{ width: "287px", height: "386px" }} /> <div className="w-8/12 h-3 absolute bottom-16 left-10 bg-gray-400 mt-3 rounded-full" /> <div className="w-6/12 h-3 absolute bottom-10 left-10 bg-gray-400 mt-3 rounded-full" /> </div> )); } Enter fullscreen mode Exit fullscreen mode Collapse Expand Dicky Saputra Dicky Saputra Dicky Saputra Follow Here, I write about technical skills, front-end development, tools, and day-to-day coding insights. Email saputradicky705@gmail.com Location Jepara, Indonesia Work Frontend Developer at Madeindonesia Joined Jul 13, 2021 • Jan 11 '22 Dropdown menu Copy link Hide great๐ฅ Code of Conduct • Report abuse For further actions, you may consider blocking this person and/or reporting abuse
Top comments (2)
You could make this a bit simpler by using new Array which lets you just say how long you want an array to be.
great๐ฅ