Bug in select element in combination with state handling #756
-
Hello there, We are working in our EditForm component so that the user can change his trip details, in this case the country and the city. After switching the country he needs to receive the cities that belong to the country. Unfortunately, after switching the country, for example, from Germany to France and then back to Germany, we receive no cities at all, although when we first switch to a different country, everything works fine. We handle the defaultCity over a state in the handleIsoCode function at the moment and we know, if this state handling will be in this function, we have to rename it. Here is the code and the PR
Thanks in advance, looking forward to your feedback ✌️ |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi there, As we already discussed, you are missing the <option selected value={defaultIsoCode}>
{country} {defaultFlag}
</option>
{countries.map(({ isoCode, flag, name }) => (
<option key={isoCode} value={isoCode}>
{name} {flag}
</option>
))} You need the countries iso code to determine the cities of the respective country. 🙂 |
Beta Was this translation helpful? Give feedback.
Hi there,
As we already discussed, you are missing the
value
attribute on your countryselect
in yourEditForm
:You need the countries iso code to determine the cities of the respective country. 🙂