Simple dropdown not working with usestate

1 Answer 68 Views
DropDownList
Daniela
Top achievements
Rank 1
Iron
Iron
Iron
Daniela asked on 27 Oct 2021, 12:59 PM

Hello,

We are implementing the dropdown from this example:https://www.telerik.com/kendo-react-ui/components/dropdowns/dropdownlist/

But setting the same array of fields with useState but we get the error "Typeerror: data.findindex is not a function" , the code is below, some get would be very appreciated.

  useEffect(()=>{
    fetchCompModelData()

  }, [])

 

constfetchCompModelData = async () => { 

  try{
    const uniqueItemsModel = uniqueElementModel(result.data);
    setCompModelData(uniqueItemsModel);
    debugger
  }catch(err){
    console.log("AXIOS ERROR"err.message);
  }

}

const uniqueElementModel = async (arr=> {  
  const datatest =  ["test",
  "GA 315",
  "V320TS",
  "RS200n-W115",
  "RS110IE-A110",
  "RS110IE-A125"];  
  return datatest
}
const [compModelDatasetCompModelData] = useState([])

return (

          <div>
           
           <div className="mb-3">
                  <label htmlFor="brand-name" className="text-info"> Model </label>
                  <DropDownList 
                      data={compModelData}
                    />  
          

</div>

      </div>        
  )
}

1 Answer, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 27 Oct 2021, 01:32 PM

Hi Daniela,

The error is most likely caused by something else, but from the provided information it will be difficult to determine the root cause of it. In the following example you can see that the DropDownList  populates correctly with useState:

If the issue on your side persists, please provide an example replicate it, so we can debug it on our end.

 

Regards,
Konstantin Dikov
Progress Telerik

Remote troubleshooting is now easier with Telerik Fiddler Jam. Get the full context to end-users' issues in just three steps! Start your trial here - https://www.telerik.com/fiddler-jam.
Daniela
Top achievements
Rank 1
Iron
Iron
Iron
commented on 27 Oct 2021, 01:39 PM

Hello, it was an error on my end, sorry about that

 

thanks

Tags
DropDownList
Asked by
Daniela
Top achievements
Rank 1
Iron
Iron
Iron
Answers by
Konstantin Dikov
Telerik team
Share this question
or