ViewPagerAndroid returns a blank view when adding new source data

I am currently using the ViewPagerAndroid component to perform a corresponding / unmatching function, which requires a dynamic update of the data in the component's source data. The children of the view pager are generated by the makeItems function (this.state.data), and it returns an array of key views. those. [<Browse key = {1} / ">, <Browse key = {2} /"> ....] with the index being the index of the for loop, which generates an array from the source data. Views contain composite views of the touch backlight, but they are all wrapped in a view container. I saved the data in the state of the component, and whenever it is updated, I call setState and ViewPagerAndroid.setPage (0). Updating data works great when I reduce data (splicing), but returns new data when I add new data to the array. The data before the update was displayed correctly. I checked the makeItems () function that the updated data was passed correctly.

< ViewPagerAndroid name = 'Page Viewer 1' style = {styles.matchingPanelViewPager} initialPage={this.state.currentPage} onPageSelected = {(e)=>{ console.log(e.nativeEvent.position); }} ref = {viewPager =>{this.viewPager = viewPager;}}> {this.makeItems(this.state.data)} </ ViewPagerAndroid> 

I am using RN0.16.0 for Mac OS X, Genymotion, Android 4.2.2.

Many thanks for your help!

+5
source share

Source: https://habr.com/ru/post/1238207/


All Articles