-
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
Creatable.js mutates props.options, effectively changing it in parent Component as well #1477
Comments
Definitely seems weird, here's a fiddle derived from your example: https://jsfiddle.net/robertmaloney/77r13rpm/ I would consider this a bug. |
If we want the Creatable to "keep track of" the fact that things that were added are valid options, it should either:
I'd highly recommend the first approach; the second seems too "magical" for such a reusable component. |
+:100:. @bpartridge's comment above exactly matches my own thoughts after running into this issue. The "convenience" of Creatable doing its own My use case: I want the Creatable-"created" option to be ephemeral: if the user ever selects another option, their created option should disappear unless they type it and explicitly create it again. I was hoping to implement this with a custom (Another solution to my problem would be if react-select had the ability to allow any text to remain in the text field, regardless of whether it matches an option. This behavior would be more similar to a combo box such as react-autocomplete.) |
Following up on this. Would the maintainers welcome a PR that implemented the first approach I suggested?
|
I'm using React 15.6.1 and seeing a full blown TypeError on this now. Has anyone else seen this?
|
The secret to happiness: never upgrade any software |
Still no updates? It is kinda pretty serious issue. For example, I have the functionality to add a new option, and after I click clear button I expect to new option to be deleted from the input as well as from the option list. But because of it, the new options remains in the option list and there is nothing I can do about it. |
It's also a big issue if your options are immutable array. ( made my day :-D ) |
Hello - In an effort to sustain the We understand this might be inconvenient but in the best interest of supporting the broader community we have to direct our efforts towards the current major version. If you aren't using the latest version of However, if you feel this issue is still relevant and you'd like us to review it - please leave a comment and we'll do our best to get back to you! |
The component
Creatable.js
has the functioncreateNewOption ()
which contains the following lineWhen this executes, it will directly mutate the
options
property, something that not only seems like an anti-pattern for React, but can result in a changed value in the Parent component as well.Given the following example, when onChange is being called after a new option has been created, the options property of the Parent component has already been changed.
Is this something that is a temporary but known behaviour that will change in the future? Is it a behaviour that is here to stay, or is it simple a bug?
The text was updated successfully, but these errors were encountered: