react-native-paper-dropdown
react-native-paper-dropdown copied to clipboard
Local state or redux state is lost in setValue
`
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 i'm facing the same issue? Have you fixed it?
I made a fix: https://github.com/tonixlaw/react-native-paper-dropdown/commits/master/src/DropDown.tsx