react-native-dropdown-select-list
react-native-dropdown-select-list copied to clipboard
Does it have a way to clear the selection?
Any updates on this issue ?
@josephhelou v 2.0.5 coming this Sunday , With Awesome improvements and Clear Function onDemand.
@danish1658 any updates regarding the release ?
Will be available tomorrow, will update you soon after the version patch
When will we get the update?
Hey, it's over 2 weeks after you say "will be available tomorrow", any news?
@danish1658, any updates? 🙏
Im sorry for the delay, i will be committing the changes anytime this weekend.
Hello, @danish1658, any updates? 🙏
Any updates on the clear option?
any updates on the clear option?????
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}
Here's a simple and straightforward way to clear the states of SelectList or MultiSelectList
In your component file
- Create a state and initialized it by 0.
const [reset, setReset] = useState(0);
- Create a function named clearStates that will handle the state reset.
const clearStates = () => {
setReset(reset + 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"
/>
- Create a button with an onPress that triggers the clearStates function.
<Button mode="contained" onPress={clearStates}>
Clear States
</Button>
Thank you @hassancodess. This is a very user friendly method that works perfectly!
@danish1658 any updates regarding the clear function? Still can't find any solution to clear the selection in your npm package.
Will this update the data when selected? Is this fix released yet?
@jaimeevelt01 https://github.com/AshrazRashid/react-native-dropdown-select-list.git