question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

dynamic+static swiper

See original GitHub issue

I have a weird issue trying to use dynamic&static content in Swiper. Im not able to use both approaches to create the result I need.

My code is:

<Swiper horizontal={false}>
          <View> ...View 1 (static header)...</View>
          {this.items.map((item, key) => {
             return (
                  <View key={key} style={styles.slide1}>
                     <Text>bla bla</Text>
                  </View>
             )
            });
          }
          <View> ... View 3 (static footer) ...</View>
</Swiper>

This will produce something like:

View 1 (static header) / View 2 --> Contains 4 childviews where each view take 1/4 of the screen / View 3 (static footer)

On the other hand, if I delete header and footer and I leave the map function alone I will see the 4 views I’m expecting… any idea?

Thanks! Juan

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:4
  • Comments:26

github_iconTop GitHub Comments

3reactions
juanluisgv1commented, Sep 19, 2016

I had the same issue. I needed to create an array of views so I guess you could do sth like this:

this.toRender = [];
this.journeyData.steps.map(function(current, index) {
        this.toRender.push( () => return (<View key={index}>
          <Text style={{textAlign:'center', 'color':'#fff', fontSize:20,marginBottom:20}}>Route Step #{current.id}</Text>
        </View>))
      });
3reactions
getnashtycommented, Sep 2, 2016

Hi Juan,

Your options are to give each slide their own header/footer (swiper may need custom styles for this to work, or place the header/footer with absolute positioning):

<Swiper horizontal={false}>
          {this.items.map((item, key) => {
             return (
                  <View>
                    <View> ...View 1 (static header)...</View>
                    <View key={key} style={styles.slide1}>
                       <Text>bla bla</Text>
                    </View>
                    <View> ... View 3 (static footer) ...</View>
                  </View>
             )
            });
          }
</Swiper>

or, wrap the swiper in the header / footer:

<View style={{flex:1, flexDirection:'column'}}>
    <View> ...View 1 (static header)...</View>
    <Swiper horizontal={false}>
          {this.items.map((item, key) => {
             return (
                  <View key={key} style={styles.slide1}>
                     <Text>bla bla</Text>
                  </View>
             )
            });
          }
    </Swiper>
    <View> ... View 3 (static footer) ...</View>
</View>
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to make static slider (Swiper JS) dynamic in Oxygen Builder
Short tutorial on how to transform static slider using Swiper JS library to dynamical one.
Read more >
Swiper Demos
Swiper is the most modern free mobile touch slider with hardware accelerated transitions and amazing native behavior.
Read more >
Mixing static and dynamic items in react-native-swiper
But if I have one static item and multiple dynamic items the swiper only shows the static + one of the dynamic. So...
Read more >
Help with dynamically embedding items in Swiper slider code
Continued using Swiper slider, but I input the static content manually from CMS Collection via custom code since it's less than 10 items ......
Read more >
Creative type insights for Amazon DSP static and dynamic ads
Are you trying to decide between static image ads, Dynamic or Responsive eCommerce Ads? Not sure if you should use a tailored headline...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found