leecade / react-native-swiper

The best Swiper component for React Native.
MIT License
10.42k stars 2.34k forks source link

dynamic views #752

Open infogod opened 6 years ago

infogod commented 6 years ago

Which OS ?

Both

Version

Latest

Expected behaviour

Add new component without recreate any other component

Actual behaviour

Everytime when I add dynamic components to Swiper all the old components are recreated.

My issue is about dynamic views. I have a component called Table inside a Swiper. According to some events on my component the system will add more tables to Swiper but when it happens all the components added are recreated but I need to add news components to the swiper keeping the state of the components already added.

example code:

 render() {
         return (
             <Swiper loop={false}  showsPagination={false} showsButtons={false}>
                 {this.tables.map((item,key)=>{
                     return (<View key={item.id} style={{flex: 1}}><Table
                                    game_id = {item.game_id}
                                    name={item.name}
                                    id={item.id}
                                    button={item.button}
                                    lateEnter={item.lateEnter}
                                    mynavigation={item.mynavigation}/></View>)
                 })}
             </Swiper>
         );
     }
 };
Asfandtnt commented 6 years ago

can you send me complete working example of dynamic slides of swiper ... i am doing the same. in my case i am showing images on each slide which are not showing... this is what i am doing inside of Swiper tag

{JSON.parse(temp[0].json_metadata).image.map((item,key)=>{ return (<View key={item.id} style={{flex: 1}}> <Image source={{uri :'https://someimage.png' }}'/>
) })}