score:-1

 

     useeffect(()=>{
       //set your state only after api data is completely fetched
   
         api('someapi').then((response)=>{
         console.log(response);// make sure this is not undefined
   
    if(response.status===200){
        setselectedvalue(response.data); 
        }
   }); 
   },[])

Related Query

More Query from same tag