Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions library/ViewPager.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export default class ViewPager extends Component {
}
}

componentDidUpdate() {
componentDidUpdate(prevProps, prevState) {
if (!this.initialPageSettled) {
this.initialPageSettled = true;
if (Platform.OS === 'ios') {
Expand All @@ -187,7 +187,7 @@ export default class ViewPager extends Component {
//A trick to solve bugs on Android. Delay a little
setTimeout(this.scrollToPage.bind(this, this.props.initialPage, true), 0);
}
} else if (this.layoutChanged) {
} else if (this.layoutChanged || prevProps.pageDataArray.length !== this.props.pageDataArray.length) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is useful and necessary when pageDataArray changed , for instance , you deleted one photo!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be done in componentWillReceiveProps not in componentDidUpdate

this.layoutChanged = false;
if (typeof this.currentPage === 'number') {
if (Platform.OS === 'ios') {
Expand Down