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.

the dots were not changing when using map to display data

See original GitHub issue

Hi I am using your module and I wrote like this :


          <Swiper index={this.state.index} style={styles.swipe} autoplay={false} horizontal={true}
            dotColor="transparent"
            activeDotColor="transparent"
            onIndexChanged={(index) => {
              alert("hi")
              this.setState({
                index: index,
              })
            }}>
            {swiperList.map((res,i)=>{
              let durationMinutes = res.duration / 60
              let durationText
              if (durationMinutes < 1) {
                durationText = res.duration + ' sec'
              } else if (isNaN(durationMinutes)) {
                durationText = ''
              } else {
                durationText = durationMinutes + ' min'
              }
              return(
                <View style={styles.swiperView}>
                  <View style={styles.addRoutineMainCardViewMainMorning}>
                    <Thumbnail large source={{uri : 'https:'+res.backgroundImage.file.url , cache: 'force-cache'}} style={styles.routineCreatedCardlogoimage} />
                    <Thumbnail source={Images.createroutinetimeButton['morning']} style={styles.routineCreatedCardOverlayimage} />
                  </View>
                  <Text style={styles.swiperText}>{res.title}</Text>
                  <Text style={styles.swipertimetext}>{durationText}</Text>
                </View>
              )
            }
            )}
          </Swiper>

here when I swiper the onIndexChanged is not at all calling And I did not use lopp but my data is showing twice Can you tell me how to fix this…

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:1
  • Comments:9

github_iconTop GitHub Comments

6reactions
frankiewonghkcommented, Dec 16, 2017

I got the same issue and I solved it by the following code:

`class Slider extends Component{ componentWillMount(){ this.props.getSliderThunk(); }

render(){ 
    if(this.props.slider.length == 0){
        return(
        <View><Text>Loading...</Text></View>
        )
    }
    else{
        return(
            <View style={styles.container}>
                <Swiper style={styles.wrapper} loop={true}>
                { 
                    this.props.slider.map((item, key) => {
                        return (
                            <View key = { key } style = { styles.slide }>                             
                            <Image style={styles.slide_image} source = {{ uri: item.image }}/>
                            </View>
                        )
                    })
                }
                </Swiper>
            </View>
        );
    }
    
}

}`

4reactions
Tennencommented, Oct 31, 2017

@bacancy-swaroopa loop is true by default, I think you are trying to render swiperList from http request, this is a bug, you cant change the number of children from <= 1 to > 1, otherwise onIndexChanged would never be triggered until next onLayout(). A simple way to solve this problem is to set a default array to swiperList, which length should be larger than 1. if this cant solve your problem, you may try the way in my fork.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dot density—ArcGIS Pro | Documentation
Dot density symbology is one way to represent quantities in polygons on a map. With dot density symbology, the data you symbolize is...
Read more >
Format a Map Chart
Format a Map chart with Projections, Areas, Labels and Series Colors. ... You have the option to not display country or region names,...
Read more >
React JS - Uncaught TypeError: this.props.data.map is not ...
The .map function is only available on array. It looks like data isn't in the format you are expecting it to be (it...
Read more >
Dot Density in Map Viewer: ArcGIS Online's Newest ...
With this new function, can you change the size of the dots that are displayed? I tried to use dot density for displaying...
Read more >
Visualizing Point Data on a Map in ArcGIS - DAsH
You can do this with graduated symbols that change based on ... You'll see that even though only one dot is displayed at...
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