Skip to content

Conversation

@luatnd
Copy link

@luatnd luatnd commented Mar 28, 2019

Reproduce step
First, init the viewpager with only 1 item:

const { items } = this.state; // items = [{...}]; // only one element
<ViewPager
    ref={c => window.ViewPagerInstance = c}
    data={items}
/>

Then, after fetching items from API, bind new items:

this.setState({ items: newItemsFromAPI })

Actual result
Can not swipe between pages.

Expected result
Can swipe.

Debuging
As I can see:

ViewPagerInstance.pageCount === 1; // still eq 1 after bind `data={list of 20 items}`

So, _getScrollEnabled function will return false
As a result, ScrollView > scrollEnabled was disabled:

<ScrollView
          ...
          scrollEnabled={this._getScrollEnabled()}
          ...

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.3%) to 53.412% when pulling 7867aa9 on luatnd:master into 4eadd62 on meinto:master.

@meinto
Copy link
Owner

meinto commented Mar 29, 2019

Hi, thanks for your pull request.

I tried to reproduce the case, but i didn't get it work like explained. When i initialize a dataSource and then update it, the Viewpager can be scrolled as expected:

// what i tried:

export default class PseudoComponent extends PureComponent {
   constructor() {
      this.state = {
         dataSource: [{ ... }]
      }
   }
   
   update = () => {
      this.setState({
         dataSource: [{...}, {...}, {...}]
      }
   }

   render() {
      return (
         <ViewPager
             ...
             data={this.state.dataSource}
         />
      )
   }
}

What other properties do you provide to the ViewPager Component?

Could be that there is an unwanted interaction between single properties.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants