hossein-zare / react-native-dropdown-picker

A single / multiple, categorizable, customizable, localizable and searchable item picker (drop-down) component for react native which supports both Android & iOS.
https://hossein-zare.github.io/react-native-dropdown-picker-website/
MIT License
971 stars 295 forks source link

state component #576

Open muammadibal opened 2 years ago

muammadibal commented 2 years ago

I had issue with big list or use it with formik fieldarray with much list. The performance when open the dropdown laggy, and then I tried create my own with the state open inside the component the problem is solve.

Is it possible make the setValue only return the callback value instead passing setState directly into setValue? because i need to mutate the value. But for that issue i've found solution with setValue={cb => { let value = cb() }}

and then the next problem is with multiple select, cannot found solution at this time

mauro-rogledi commented 1 year ago

For another problem, I also need the same functionality too I use a context with useReducer. In this way the DropDownPicker never changes the selected value also because the onChangeValue is never called.

BTW If you have another solution .....

Thanks in advance

export function PreferencesScreen({navigation}) {

    const {theme, dispatch} = useContext(ThemeContext);
    const [value, setValue] = useState('');

      <DropDownPicker
        items={listElem}
        open={open}
        setOpen={setOpen}
        value={theme.background}
        setValue={setValue}
        zIndex={1000}
        zIndexInverse={2000}
        onChangeValue={v => {
          dispatch({action: TypeAction.CHANGE, payload: v ?? ''});
        }}
      />