hossein-zare / react-native-dropdown-picker

A single / multiple, categorizable, customizable, localizable and searchable item picker (drop-down) component for react native which supports both Android & iOS.
https://hossein-zare.github.io/react-native-dropdown-picker-website/
MIT License
992 stars 296 forks source link

"null is not an object" on selection #575

Open ginnyedelstein opened 2 years ago

ginnyedelstein commented 2 years ago

const [categoryOpen, setCategoryOpen] = useState(false); const [categoryValue, setCategoryValue] = useState(null); const [categoryItems, setCategoryItems] = useState([ { label: "General", value: "general" }, { label: "Technology", value: "technology" }, ]); const [radiusOpen, setRadiusOpen] = useState(false); const [radiusValue, setRadiusValue] = useState(null); const [radiusItems, setRadiusItems] = useState([ { label: "5km", value: "5" }, { label: "unlimited", value: "0" }, ]);

const onCategoryOpen = useCallback(() => { setRadiusOpen(false); }, []);

const onRadiusOpen = useCallback(() => { setCategoryOpen(false); }, []);

return (

{ alert(value); }} onOpen={onCategoryOpen} /> { alert(value); }} onOpen={onRadiusOpen} /> {help.map((request) => ( {request} ))}

when i try to select select a value im getting "null is not an object (evaluating 'memoryRef.current.value.includes')

hossein-zare commented 2 years ago
const [categoryValue, setCategoryValue] = useState([]); 

https://hossein-zare.github.io/react-native-dropdown-picker-website/docs/usage#multiple-items

ginnyedelstein commented 2 years ago

thanks! can i set it to an initial value? this isnt working: const [radiusValue, setRadiusValue] = useState([ { label: "unlimited", value: "0" }, ]);

hossein-zare commented 2 years ago

useState(0); will do that for you.