I want to add dynamically component in <Swiper>
?
Like that:
React.useEffect(()=>{
setDataArray([...data, newData]); // newData is just an example.
},[index])
return (
<Swiper
horizontal={true}
loop={false}
onIndexChanged={(i)=>{
if (i == dataArray.length)
setIndex(i)
}}
>
{
dataArray.map((props, i)=>(
<Swiper_Child
key={'key_'+i}
{...props}
/>
))
}
</Swiper>
);
Because when dataArray
have a new element to create a new Swiper_child
component, Swiper
does not change the number of page to swipe...
How to do it ?