Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

always set this.pageCount #5

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

always set this.pageCount #5

wants to merge 3 commits into from

Conversation

ksti
Copy link

@ksti ksti commented Sep 20, 2016

I should always set this.pageCount.
I used this in the project:ksti/react-native-photo-browser
Thanks for your awesome works!

@ksti ksti mentioned this pull request Sep 20, 2016
…ngth !== this.props.pageDataArray.length, maybe I deleted one photo\!
Copy link
Author

@ksti ksti left a comment

Choose a reason for hiding this comment

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

this should be necessary

@@ -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

@@ -178,6 +178,19 @@ export default class ViewPager extends Component {
}
}

componentWillReceiveProps(nextProps) {
if (nextProps.initialPage !== this.props.initialPage) {
Copy link
Author

Choose a reason for hiding this comment

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

if initialPage changed , then scroll to nextProps.initialPage.
this code should be put in componentWillReceiveProps not in componentDidUpdate

@shercoder
Copy link

It would be great to get this PR merged.

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.

2 participants