-
Notifications
You must be signed in to change notification settings - Fork 24.5k
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
call onValueChange only when value changes #24653
Conversation
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.
Code analysis results:
eslint
found some issues. Runyarn lint --fix
to automatically fix problems.
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.
Yeah this makes sense to me. Thank you for the PR!
cc @Kudo since you recently fixed an issue with |
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.
@cpojer is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
This pull request was successfully merged by @a-c-sreedhar-reddy in 82148da. When will my fix make it into a release? | Upcoming Releases |
Thanks @cpojer. Hey @a-c-sreedhar-reddy, just to clarify which RN version you used. |
@Kudo This is what I tested with. |
That's weird to me since I tested with the exact same version. @Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
// onItemSelected gets fired immediately after layout because checkSelectionChanged() in
// AdapterView updates the selection position from the default INVALID_POSITION.
// To match iOS behavior, which no onItemSelected during initial layout.
// We setup the listener after layout.
if (getOnItemSelectedListener() == null)
setOnItemSelectedListener(mItemSelectedListener);
} |
@Kudo You are right. May be I did not update node modules. Sorry for this. Should I make a PR removing this change? |
@a-c-sreedhar-reddy Sorry missed this. Your fix is fine for me. |
Summary
OnValueChange
function ofPicker
is called when Picker is initialized.Changelog
[Android][fixed] -
OnValueChange
will be called only when theselectedValue
changes.Test Plan
Here
state.test
must be 1 when the app loads. But theonValueChange
is called initially which changesstate.test
to 2. This pull request fixes the issue.