Get the individual option that was added or removed onChange?
See original GitHub issueMaybe I’m missing something, but I can’t seem to find it anywhere in the docs. When using multi select, the onChange
handler only returns the new array of items. There is no way to tell which option was added or removed.
Is there any handler that can tell me which option was removed and which option was added instead of a complete array of currently selected options?
Issue Analytics
- State:
- Created 7 years ago
- Reactions:15
- Comments:6 (1 by maintainers)
Top Results From Across the Web
reactjs - How to catch remove event in react-select when ...
So, to detect if some option was removed, you would have to compare the current state with the new values the onChange emitted....
Read more >How to add & remove owners & managers for your Business ...
Owners of Business Profiles can invite users to become owners and managers. Each person can have their own access and they don't share...
Read more >Change, remove or turn off animation effects - Microsoft Support
Although you can't remove all animations from an entire presentation in one step (you have to remove animations from each object individually, as...
Read more >Renew, change, update, or cancel your health plan for 2023
If you have Marketplace health insurance in 2022, you can renew, change, or update your plan for 2023 until January 15, 2023. Enroll...
Read more >Change Your Flood Zone Designation | FEMA.gov
How to Submit a Letter of Map Change (LOMC) Request · Homeowners, Renters, Community Officials and Other Individuals · Land Surveyors, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
yeah, this library is incredible, but i found this design decision difficult to understand
I’m just using a simple diff function
onChange
for now.Here’s a snippet of my solution. I just picked this library up today, so it’s likely this isn’t the optimal way to do this, but I’m procrastinating atm, so what the hell. Note a few caveats for my use case:
Creatable
, I’ve assigned the handler toonNewOptionClick
as welloptions
as an array ofobjects
, I’ve just used thesimpleValue
option so that myonChange
handler receives a comma-delimited string instead of an array of objects. Unnecessary for an example this trivial, but on larger arrays, I imagine this might make a difference.This works for my use case, but given how customizable this component is, I doubt it’s copy-pasta for everyone.
So if user clicks to delete ‘Fake Tag2’, the console logs
two
, andtrue
If they add the custom value ‘Fake Tag99’, the console logs
'Fake Tag99'
andfalse
It’s a bit inconsistent, because clicking an item gets you the
value
, while custom creations get you what amounts to thelabel
, but afaik it’s the only way.Did the same as @brandonmp. I’ve a list of item already selected for my item. In the
onChange
function of theSelect
i do this:if(this.state.myItemSelectedValues.length > onChangeNewVal)
this.state.myItemSelectedValues
arrayonChangeNewVal
array does not include mythis.state.myItemSelectedValues[i]
(use.includes()
function), I unshift or push it in my available options array