React-native-swiper: Mixing static and dynamic items

Created on 15 Sep 2017  路  2Comments  路  Source: leecade/react-native-swiper

Hi,

I saw, that you added support for dynamic items. This is working well. Using multiple static items is working well too. But if I have one static item and multiple dynamic items the swiper only shows the static + one of the dynamic. So I always get two "pages".

Any ideas how to solve this?

Most helpful comment

I dont know if this will help you but I had a similar problem and I solved it with something like this. Making a new array containing the dynamic and static items using ES6 spread seems to fix it.

render(){
    const generatedArray = something.map(thing => somethingToReturn);
    return(
        {
        [
          // previously defined array which will get updated at some point
        ...generatedArray,
        // static slide
        <View style={styles.slide} key={uuid.v4()}>
          <Button
            title="end quiz"
            action={() => console.log("ended")}
          />
        </View>,
        ]
        }
    )
}

All 2 comments

I dont know if this will help you but I had a similar problem and I solved it with something like this. Making a new array containing the dynamic and static items using ES6 spread seems to fix it.

render(){
    const generatedArray = something.map(thing => somethingToReturn);
    return(
        {
        [
          // previously defined array which will get updated at some point
        ...generatedArray,
        // static slide
        <View style={styles.slide} key={uuid.v4()}>
          <Button
            title="end quiz"
            action={() => console.log("ended")}
          />
        </View>,
        ]
        }
    )
}

Your workaround works fine ! Thanks !

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Liqiankun picture Liqiankun  路  3Comments

nomoreboredom picture nomoreboredom  路  3Comments

wrannaman picture wrannaman  路  3Comments

commit-master picture commit-master  路  3Comments

kylehagler picture kylehagler  路  3Comments