-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dropdown value not populated on initial render w/ react 16 #1682
Comments
Hm, I wouldn't think setting state directly in CWM would be much different than using an ES6 property initializer. Both set state directly, before the component mounts, and do not invoke For now, can you use We'll revisit how the ACC is handling state, notably, initial state. |
@levithomason - Here is the block of code which explains both my code works, and why the current implementation does not... Perhaps this is a bug in react-fiber? Notice that the state is stored in a local variable prior to calling The result is that The reason my hack works is, I make That should make sense? Let me know if I should or can explain any further ) |
I've updated the forked pen to include two options so you can see this in action: http://codepen.io/levithomason/pen/YVjLwy |
@levithomason - I appreciate your help on this issue. I must be missing something. I see the following error:
Looks like it is coming from here:
|
Can confirm that the latest fix has resolve this issue 👍 |
Steps
Expected Result
California would be selected/active
Actual Result
Placeholder is shown
Version
[email protected]
[email protected]
Testcase
http://codepen.io/anon/pen/jmpavw
Upon further investigation it looks like semantic-ui-react is following some conventions not recommended by the react docs. Specifically I tracked the issue down to:
https://github.com/Semantic-Org/Semantic-UI-React/blob/v0.68.3/src/lib/AutoControlledComponent.js#L149
This turns out to be a messy problem. The dropdown is dependent on
this.state
being set sync (it usesthis.state.value
in order to find theselectedIndex
), but the state needs to be set with the asyncsetState
method otherwise it gets blown out on the event loop thatsetState
finally fires.There may need to be a larger discussion around how controlled components behave, but I was able to side step the problem by replacing the above line with:
The overall idea being it can take advantage of
this.state
being set sync but it doesn't get blown out because I also add the update to thesetState
queue.The text was updated successfully, but these errors were encountered: