I am trying to dynamically create a SwiperSlide tag inside a map function. The docs in Swiper JS are hard coded but I would like them to be dynamically.
The replicable code is here – https://codesandbox.io/p/sandbox/swiper-react-effect-coverflow-forked-67pckv?file=%2Fsrc%2FApp.jsx%3A21%2C30
in Line 35 even if I try to specify the SwipeSlide inside the map using JSX syntax it’s not reflecting anything in the output. Need help in this.
{items.map((item) => {
<SwiperSlide>{item}</SwiperSlide>
})}
>Solution :
You are not returning the SwiperSlide from map function, please update as following:
{items.map((item) => {
return(
<SwiperSlide>{item}</SwiperSlide>
)
})}
Or you can do this as well:
{items.map((item) => (
<SwiperSlide>{item}</SwiperSlide>
))}