React-Native-ViewPager icon indicating copy to clipboard operation
React-Native-ViewPager copied to clipboard

Not working with dynamic elements

Open ravirupareliya opened this issue 8 years ago • 5 comments

When i am using it with static data, it is working perfectly. But when i tried to use dynamic data, it is not showing anything.

<IndicatorViewPager
          style={{ height: 200 }}
          indicator={this._renderDotIndicator()}
        >
          {
            mediaData.map((item, i) =>
              this.renderRow(item, i)
            )
          }
</IndicatorViewPager>

const mediaData = [
    {
       url: ''
    },
    {
      url: ''
    }, 
    {
     url: ''
    }
]

and in renderRow

renderRow(item, i) {
    return (
      <View style={{backgroundColor:'cadetblue'}}>
           <Text>page one</Text>
      </View>
    )
  }

But it is just showing blank views, however if i try it with static data then it is working perfectly fine.

ravirupareliya avatar Oct 04 '17 05:10 ravirupareliya

Maybe you should consider that when data is empty. When data is empty you should return an empty view.

zbtang avatar Oct 16 '17 14:10 zbtang

What if we don't know many empty pages will required

farruxx avatar Oct 16 '17 18:10 farruxx

Any success on this thing?

Doychev avatar Jan 10 '18 10:01 Doychev

mediaData I am passing the data dynamically. but, changes are reflecting only in first slide. schedules

Someone please tell me, what is wrong. if i give static, its working fine!

Johncy1997 avatar Feb 19 '19 09:02 Johncy1997

@ravirupareliya You should add flex: 1 style into your View. That would work i guess.

@Johncy1997 Can you try that too? Each child should be wrapped with a View with flex: 1 style.

YeshanJay avatar Mar 13 '20 11:03 YeshanJay