SelectValue doesn't re-render value on state update #2677
Unanswered
janoschherrmann
asked this question in
Help
Replies: 1 comment
-
Can you set it as the default value here? const [selectedCountryCode, setSelectedCountryCode] = useState<CountryCode>(
Cookies.get('countryCode') as CountryCode
);` |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey there, I want to implement a country switcher using the
Select
component. When the component renders, it checks for a previously selected country in a cookie, which is then used as the initialSelectValue
.What is weird is that even though the value from the cookie gets read correctly and the
selectedCountryCode
gets updated, theSelectValue
doesn't render with the correctly updated value. It stays empty. Is does work though, if I set an initial value forselectedCountryCode
(initialuseState
value), but that's not what I want, since the default value should come from the cookie and only as a last resort be set to thedefaultCountryCode
.Any ideas why this might be happening?
Beta Was this translation helpful? Give feedback.
All reactions