Define/update "Value" of DropDownList using a state-variable does not work

Hi,
I want to set the value of my DropDownList from a React state variable, but unfortunately, when I modify my state variable, it does not update the dropdownlist's value.
I have attached a demo code piece, which shows the problem.

Thanks.

Attachment: index_f0578aa1.zip

8 Replies 1 reply marked as answer

SN Sevvandhi Nagulan Syncfusion Team April 14, 2021 06:20 AM UTC

Hi Laurin, 


Greetings from Syncfusion support. 


We have validated the reported issue. On analyzing the provided sample, you are in need of updating state which is component’s value property inside useEffect() hook. In order to achieve this, we suggest you to update the state inside the callback of a timeout. Please refer to the code snippet below. 
 
 
 useEffect(() => { 
    setTimeout(function() {setValue("Game3")}); 
  }, []); 
 



Please find the sample below. 




Kindly get back to us for further assistance. 


Regards, 
Sevvandhi N 



LS Laurin S April 14, 2021 07:13 AM UTC

Is that really the suggested solution/way, to solve this problem? Seems to me just as a workaround, but not as the most correct solution...

I have the following use case scenario:
I want to show a form, where I fetch the data from a REST API call. Once I obtain the api response, I'm saving the obtained field values in a state variable, that should update the various form fields. I thinks that is the recommended way of React. Cannot believe that using the setTimeout function is the correct way... Any other suggestion or idea? Or am I doing something wrong?


SN Sevvandhi Nagulan Syncfusion Team April 19, 2021 12:06 PM UTC

Hi Laurin, 


We are currently validating the reported issue at our end.  We will update further details on 21st, April 2021. We appreciate your patience until then. 


Regards, 
Sevvandhi N 



SN Sevvandhi Nagulan Syncfusion Team April 30, 2021 04:42 AM UTC

Hi Laurin, 


Thanks for your patience. 


We considered the reported issue (“Value is not updated if we update the state in useEffect() hook for Dropdownlist”)as a bug at our end. We will include the fix for the reported issue in the May 19th,2021 patch release. We appreciate your patience until then.     


You can track the status of the reported issue from the feedback link below. 




Regards, 
Sevvandhi N 



SN Sevvandhi Nagulan Syncfusion Team May 19, 2021 01:09 PM UTC

Hi Laurin,   


 
Sorry for the inconvenience caused.  


 
Due to some complexities, the fix will not be included on May 19th ,2021 patch release. We will include the fix this issue on May 26th ,2021 patch release. We appreciate your patience until then.   


 


 
Thanks,   
Sevvandhi N  



SN Sevvandhi Nagulan Syncfusion Team May 26, 2021 11:55 AM UTC

Hi Laurin,    


  
Sorry for the inconvenience caused.   


  
Due to some complexities, the fix will not be included on May 26th ,2021 patch release. We will include the fix this issue on June 2nd ,2021 patch release. We appreciate your patience until then.    


  


  
Thanks,    
Sevvandhi N   




SN Sevvandhi Nagulan Syncfusion Team June 2, 2021 10:36 AM UTC

Hi Laurin,     


   
Sorry for the inconvenience caused.    


   
Due to some complexities, the fix will not be included on June 2nd ,2021 patch release. We will include the fix this issue on June 9th ,2021 patch release. We appreciate your patience until then.     


   
  

   
Thanks,     
Sevvandhi N    



SN Sevvandhi Nagulan Syncfusion Team June 9, 2021 08:07 AM UTC

Hi Laurin, 


Thanks for your patience. 


We are glad to announce that our latest patch release v19.1.67 has been rolled out successfully and in that release, we have included the fix for “Define/update "Value" of DropDownList using a state-variable does not work”. So, we suggest you to upgrade the package version to the latest to resolve the issue. 


Regards, 
Sevvandhi N 


Marked as answer
Loader.
Up arrow icon