-
Notifications
You must be signed in to change notification settings - Fork 734
WheelPicker (incubator) - fix updates #1693
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
Conversation
…when 'initialValue' changes
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.
Looks great!
Wrote a single comment
src/incubator/WheelPicker/index.tsx
Outdated
|
||
if (prevInitialValue.current !== initialValue) { | ||
// don't invoke 'onChange' if 'initialValue' changed | ||
prevInitialValue.current = initialValue; |
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.
I wouldn't set the prevInitialValue
value here just because scrollToIndex
method is being called in several places.
Instead I'd set in the useEffect
that handle the initialValue update (right after triggering the scroll)
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.
Not sure I understand. In all other cases, it should not pass the condition...
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.
Yes but technically the responsibility for re-setting the prevInitialValue
is in the relevant useEffect and not in the method it calls to.
If someone will change the implementation of scrollToIndex
they might break the functionality of prevInitialValue
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.
I don't see how it works... Let's talk when you're available
Description
WheelPicker (incubator) - allow 'items' change; block 'onChange' call when 'initialValue' change.
Changelog
WheelPicker (incubator) - allow 'items' change; block 'onChange' call when 'initialValue' change.