-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Inconsistent API: Setting the Select value programatically is possible only with strings (not with objects like options or asyncOptions) #409
Comments
It seems possible with I close this as a duplicate of #420. |
@mik01aj Did you get it working so that you could set the |
After reporting the issue, I rewrote my code so that the select uses only ids, and the data is fetched from some other place (so I don't need it in my component anymore). But I do use |
Ah ok. That makes sense. I am just using |
Reopening as of #420 (comment) |
👍 We have this issue as well, and the What we suggest is an These could still work nicely in tandem with each other. |
+1 @Bertg |
I'd actually really like to update react-select to work with complex It was originally written for the "drop into a form" use-case, but for more complex applications where you're controlling props & value from higher-level components I agree it's clunky. Hopefully will have some time to look into this in the near future; if anyone else wants to work on the refactor with me, please shout out. |
resolved in v2, we now only allow values to be passed in as objects for a normalised api. |
react-select
is pretty nice when used on its own, but I find it hard to integrate with other components.In particular, the only way to change the value programmatically it to update the
value
prop. But this has a serious problem: whileoptions
andasyncOptions
can contain objects,value
is only a string. The API is inconsistent here.Think about this use case: I want an input for users to invite, and they should be shown with avatar. This limitation here means that if the user already added some friends to invite (they are objects with name and avatar url), after any programmatic change the avatars will disappear.
(For me, it means that I have to work it around by stopping using objects in
options
and save them somewhere else, and then get them invalueRenderer
)The text was updated successfully, but these errors were encountered: