Open vivek25constants opened 4 years ago
I am facing the same problem. Did you find a solution please?
same problem
+1
make the defaultValue part of the state. That way every time it changes the page will re-render
Facing the same problem. I initialize selected index in state to 0 and after an API call, I update the state with the new index but the selected item doesn't change.
any example? , I didn't understand how to set the value.
@leandrorocha suppose I make the dropdown with options as numbers from 1 to 10. I initialized it using the default value 1. Then, I make an API call to fetch the actual value from backend and updated the default value variable to that value say 5. The problem is, the dropdown selected value doesn't change to 5 and remains at 1.
defaultValue works only for the first time, changing it does not updated the value.