-
Notifications
You must be signed in to change notification settings - Fork 54
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
base: master
Are you sure you want to change the base?
Conversation
…ngth !== this.props.pageDataArray.length, maybe I deleted one photo\!
There was a problem hiding this 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) { |
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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
It would be great to get this PR merged. |
I should always set this.pageCount.
I used this in the project:ksti/react-native-photo-browser
Thanks for your awesome works!