react-native-paper-dropdown icon indicating copy to clipboard operation
react-native-paper-dropdown copied to clipboard

Local state or redux state is lost in setValue

Open Softkeydel opened this issue 3 years ago • 2 comments

`

import React, { useState } from "react"; import { StyleSheet, View, FlatList } from "react-native"; import DropDown from "react-native-paper-dropdown";

function App() {

const [showDropDown, setShowDropDown] = useState(false);

const [gender, setGender] = useState();

const [dishes, setDishes] = useState( [ { title: "Main dishes", data: ["Pizza", "Burger", "Risotto"] }, { title: "Sides", data: ["French Fries", "Onion Rings", "Fried Shrimps"] }, { title: "Drinks", data: ["Water", "Coke", "Beer"] }, { title: "Desserts", data: ["Cheese Cake", "Ice Cream"] } ]);

const setValue = (v) => { console.log(dishes) //here sometimes getting empty array }

return ( <FlatList data={dishes} renderItem={({item,index}) => <DropDown label={"Dishes"} mode={"outlined"} visible={showDropDown} showDropDown={() => setShowDropDown(true)} onDismiss={() => setShowDropDown(false)} value={v} setValue={setValue} list={item.data} />}

  />

);

}

` Sometimes I'm getting redux state or local state empty in setValue. Please help explaining the issue & a solution if possible.

Thanks

Softkeydel avatar Nov 24 '21 18:11 Softkeydel

@Softkeydel i'm facing the same issue? Have you fixed it?

aliiqbal436 avatar Jun 06 '22 10:06 aliiqbal436

I made a fix: https://github.com/tonixlaw/react-native-paper-dropdown/commits/master/src/DropDown.tsx

tonixlaw avatar Dec 15 '22 01:12 tonixlaw