You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
I have been trying to use react-native-select-dropdown, but as soon as I try to use it my app crashes with the following error (and if I try to load the app with the code already inside I don't get an error, it just seems to load expo indefinitively, very weird)..
The error when I add the element to the code:
ERROR Warning: Invalid hook call. Hooks can only be called inside of the body of a function component.
This error is located at:
in SelectDropdown (created by SelectUserToken)
in RCTView (created by View)
I tried with two pieces of code, one derivated from the example to check if I just didn't write things properly:
// Higher in the codeconst[selected,setSelected]=useState("");const[selected2,setSelected2]=useState("");constdata=[{key: "1",value: "Toothbrush"},{key: "2",value: "Laptop"},{key: "3",value: "Sunglasses"},{key: "4",value: "Baseball"},{key: "5",value: "Scissors"},{key: "6",value: "Bicycle"},{key: "7",value: "Camera"},{key: "8",value: "Umbrella"},{key: "9",value: "Backpack"},{key: "10",value: "Water bottle"}];// In the display section<SelectDropdowndata={data}placeholder="User"onSelect={(val,index)=>setSelected2(val.value)}/>
<SelectDropdowndata={data}onSelect={(selectedItem,index)=>{console.log(selectedItem,index);}}renderButton={(selectedItem,isOpen)=>{return(<View><Text>{selectedItem?.value||"Select an item"}</Text></View>);}}renderItem={(item,index,isSelected)=>{return(<Viewstyle={{
...(isSelected&&{backgroundColor: '#D2D9DF'}),}}><Text>{item.title}</Text></View>);}}/>
Neither worked.
The text was updated successfully, but these errors were encountered:
I have it installed in my expo project and it worked out of the box. In the code you provided, you put your dropdown outside of a component, which is why it seems to be erroring.
Hello,
I have been trying to use react-native-select-dropdown, but as soon as I try to use it my app crashes with the following error (and if I try to load the app with the code already inside I don't get an error, it just seems to load expo indefinitively, very weird)..
The error when I add the element to the code:
I tried with two pieces of code, one derivated from the example to check if I just didn't write things properly:
Neither worked.
The text was updated successfully, but these errors were encountered: