Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

react-native-swiper add child dynamically

$
0
0

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 ?


Viewing all articles
Browse latest Browse all 6287

Trending Articles