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

Reset to empty select option

Open poinch opened this issue 2 years ago • 2 comments

Hi there,

i'll try to explain the issue i'm facing at the moment. I'm using the Select list in this way:

<SelectList data={dropDownBuyableGiftCards} setSelected={(id: string) => selectGiftCardAmountHandler(id)} placeholder="Scegli il valore" search={false} boxStyles={styles.dropdown} inputStyles={styles.dropdownText} dropdownStyles={styles.dropdownItemsContainer} dropdownTextStyles={styles.dropdownText} defaultOption={{ key: null, value: null }} />

where selectGiftCardAmountHandler it's a function that dispatch a action to a reducer:

const selectGiftCardAmountHandler = (id: string) => { const giftCardToBuy = buyableGiftCards.find((buyableGiftCard) => buyableGiftCard.id === id); dispatch(addGiftCardAmountToBuy({ id: giftCardToBuy.id, amount: giftCardToBuy.voucher.gift.amount })); };

Everything looks good, after the purchase of the gift card mentioned in my code i will go back to my home page and then if i go back to the gift card section the previous values are still selected BUT if i go back again and enter the gift card again the values will reset.

Looks like needs 2 re render to reset. I also have a: useEffect(() => { (async () => { const buyableGiftCards = await getBuyableGiftCards(); dispatch(addBuyableGiftCards(buyableGiftCards)); })(); dispatch(resetGiftCardToBuy()); }, [giftcardToBuy]);

where resetGiftCardToBuy reset all my data selected but i don't think this will help.

Anyone could help please

poinch avatar Oct 19 '22 08:10 poinch

Thanks for raising this issue, i understood the rendering issue and will fix this in upcoming version

danish1658 avatar Oct 20 '22 12:10 danish1658

@danish1658 Thank you, appreciate it

poinch avatar Oct 20 '22 14:10 poinch

I think I am also facing the same issue, not able to reset the dropdown to its initial and original view. I have a form after submitting I want to reset the dropdown to its original view. Please help by fixing this issue. Appreciate the work... Thanks in Advance.

MohanNaidu69 avatar Nov 01 '22 13:11 MohanNaidu69

@MohanNaidu69 Version 2.0 is ready , This issue has been resolved in new version , expect an update anytime soon

danish1658 avatar Nov 03 '22 14:11 danish1658

v2 is out now , see if issue is fixed , if not you can reopen this issue

danish1658 avatar Nov 09 '22 19:11 danish1658