react-native-dropdown-select-list icon indicating copy to clipboard operation
react-native-dropdown-select-list copied to clipboard

Does it have a way to clear the selection?

Open myt-sheila opened this issue 1 year ago • 17 comments

myt-sheila avatar Jan 26 '23 10:01 myt-sheila

Any updates on this issue ?

josephhelou avatar Feb 02 '23 16:02 josephhelou

@josephhelou v 2.0.5 coming this Sunday , With Awesome improvements and Clear Function onDemand.

danish1658 avatar Feb 02 '23 16:02 danish1658

@danish1658 any updates regarding the release ?

josephhelou avatar Feb 06 '23 14:02 josephhelou

Will be available tomorrow, will update you soon after the version patch

danish1658 avatar Feb 06 '23 15:02 danish1658

When will we get the update?

SGamrekelashvili avatar Feb 13 '23 14:02 SGamrekelashvili

Hey, it's over 2 weeks after you say "will be available tomorrow", any news?

AlekoG avatar Feb 20 '23 13:02 AlekoG

@danish1658, any updates? 🙏

myt-sheila avatar Feb 24 '23 02:02 myt-sheila

Im sorry for the delay, i will be committing the changes anytime this weekend.

danish1658 avatar Feb 24 '23 05:02 danish1658

Hello, @danish1658, any updates? 🙏

myt-sheila avatar Mar 07 '23 01:03 myt-sheila

Any updates on the clear option?

stefan1230 avatar Mar 10 '23 19:03 stefan1230

any updates on the clear option?????

vtxmg avatar May 06 '23 09:05 vtxmg

any update with clear selected? thx

============================================ update
simple but useful :XD

SelectList.tsx

import React, { useImperativeHandle,forwardRef  } from 'react';
...
const SelectList: React.FC<SelectListProps> =  forwardRef((props,ref) => {
    ...
    useImperativeHandle(ref, () => {
        return {
            resetData: resetData,
        };
    });

    const resetData = () => {
        setSelectedVal("")
        setSelected("")
    }
    ...
})

Use.tsx

const SelectRef = useRef(null);
...
 <SelectList data={option} save="key" ref={SelectRef} />
...
const cleanFuc = () => { SelectRef.current && SelectRef.current.resetData}

WangShayne avatar May 22 '23 09:05 WangShayne

Here's a simple and straightforward way to clear the states of SelectList or MultiSelectList

In your component file

  1. Create a state and initialized it by 0.
const [reset, setReset] = useState(0);
  1. Create a function named clearStates that will handle the state reset.
const clearStates = () => {
  setReset(reset + 1)
};
  1. Use the key prop of the MultipleSelectList component and set it to the reset state. This will trigger the component to unmount and remount when changed.
<MultipleSelectList
  key={reset}
  placeholder="Select People"
  searchPlaceholder="Search People..."
  setSelected={val => setSelectedPeople(val)}
  data={people}
  save="name"
  label="Persons"
/>
  1. Create a button with an onPress that triggers the clearStates function.
<Button mode="contained" onPress={clearStates}>
  Clear States
</Button>

hassancodess avatar Jun 13 '23 16:06 hassancodess

Thank you @hassancodess. This is a very user friendly method that works perfectly!

faisalaltell12 avatar Jun 17 '23 13:06 faisalaltell12

@danish1658 any updates regarding the clear function? Still can't find any solution to clear the selection in your npm package.

srijit-ops avatar Jul 11 '23 07:07 srijit-ops

Will this update the data when selected? Is this fix released yet?

jaimeevelt01 avatar Aug 17 '23 19:08 jaimeevelt01

@jaimeevelt01 https://github.com/AshrazRashid/react-native-dropdown-select-list.git

AshrazRashid avatar Feb 20 '24 08:02 AshrazRashid