首页 > 解决方案 > How to capture removed item in AsyncTypeahead when removing item from the list

问题描述

bootstrap-typeahead for add multiple items to a list.

https://github.com/ericgio/react-bootstrap-typeahead

I need to pick the value, when I remove an item from the list. onChange event of the AsyncTypeahead handling the event when removing and adding items to the list.

When an item removed, selected data updating with the existing values in the list.

Eg: I have 3 items in the list, I am removing an item, Then the selected list containing existing items. (2 items)

In my project I want to get that removed item, at the time of removing.

Is there any functionality for pick that removed value in "onChange" event.

标签: asynchronousreact-bootstrapreact-bootstrap-typeahead

解决方案


我遇到了同样的问题,我以这种方式对其进行了排序:

将您当前选择的项目与您之前选择的项目进行比较onchange。例如:

 const removedItem = this.state.alradySelectedItems.filter(value => !selected.includes(value));

推荐阅读