MCPcopy Create free account
hub / github.com/adobe/react-spectrum / remove

Function remove

packages/react-stately/src/data/useListData.ts:283–305  ·  view source on GitHub ↗
(...keys: Key[])

Source from the content-addressed store, hash-verified

281 dispatch(state => insert(state, state.items.length, ...values));
282 },
283 remove(...keys: Key[]) {
284 dispatch(state => {
285 let keySet = new Set(keys);
286 let items = state.items.filter(item => !keySet.has(getKey!(item)));
287
288 let selection: Selection = 'all';
289 if (state.selectedKeys !== 'all') {
290 selection = new Set(state.selectedKeys);
291 for (let key of keys) {
292 selection.delete(key);
293 }
294 }
295 if (cursor == null && items.length === 0) {
296 selection = new Set();
297 }
298
299 return {
300 ...state,
301 items,
302 selectedKeys: selection
303 };
304 });
305 },
306 removeSelectedItems() {
307 dispatch(state => {
308 if (state.selectedKeys === 'all') {

Callers 2

visitMethod · 0.50
removeMethod · 0.50

Calls 3

deleteMethod · 0.80
filterMethod · 0.65
hasMethod · 0.65

Tested by

no test coverage detected