Skip to content

Conversation

JDMathew
Copy link
Contributor

@JDMathew JDMathew commented Apr 5, 2022

The types specified for SetValue, SetOpen and SetItems are incorrect because we explicitly pass a call back or a value in the Picker. The types used were the generic React Types for SetState

For example see SetValue here:

setValue(state => {
if (multiple) {
let _state = state !== null ? [...state] : [];
if (_state.includes(item[_schema.value])) {
// Remove the value
if (Number.isInteger(min) && min >= _state.length) {
return state;
}
const index = _state.findIndex(x => x === item[_schema.value]);
_state.splice(index, 1);
} else {
// Add the value
if (Number.isInteger(max) && max <= _state.length) {
return state;
}
_state.push(item[_schema.value]);
}
return _state;
} else {
return item[_schema.value];
}
});

The types specified for `SetValue`, `SetOpen` and `SetItems` are incorrect because we explicitly pass a call back or a value in the Picker.

For example see `SetValue` here: https://github.com/hossein-zare/react-native-dropdown-picker/blob/743acd6eaaa28f149cd025d7108c97dbe8ff6de1/src/components/Picker.js#L1229
@hossein-zare
Copy link
Owner

Thank you for the changes.

@hossein-zare hossein-zare merged commit 67e605e into hossein-zare:dev-5.x Apr 7, 2022
@hossein-zare hossein-zare mentioned this pull request Apr 8, 2022
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