adammcarth / react-native-segmented-picker

Selection picker wheel with multi-column support and optional native dependencies.
MIT License
96 stars 31 forks source link

Feature/on value change expose selections #70

Closed Jono-Chang closed 2 years ago

Jono-Chang commented 2 years ago

Problem:

onValueChange tells us when the user interacts with the picker, and provides the column and value of the event. However, when we edit the options prop after the initial render, we do not know what is shown as selected to the user.

Solution:

Pass the selections out as a parameter when onValueChange is called as an additional argument.

Notes

Ive left this as a draft at the moment, as the unit test for this is difficult to make consistent due to race conditions (Hence the expect.any(String)), and I am yet to test the changes on a real device.

Jono-Chang commented 2 years ago

Closing this for now. The proposal, won't work. The sequence of events goes like:

  1. We get a onValueChange event
  2. We change the options prop
  3. We need to know the state of the picker with the new options The proposal tries and get the state of the picker on step 1, which is obviously wrong.