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

Function onDrop

packages/dev/s2-docs/pages/react-aria/DropTarget.tsx:17–34  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

15 let {dropProps, isDropTarget} = useDrop({
16 ref,
17 async onDrop(e) {
18 let items = await Promise.all(
19 (e.items as TextDropItem[])
20 .filter(
21 item =>
22 item.kind === 'text' &&
23 (item.types.has('text/plain') || item.types.has('my-app-custom-type'))
24 )
25 .map(async (item: TextDropItem) => {
26 if (item.types.has('my-app-custom-type')) {
27 return JSON.parse(await item.getText('my-app-custom-type'));
28 } else {
29 return {message: await item.getText('text/plain')};
30 }
31 })
32 );
33 setDropped(items);
34 }
35 });
36
37 let message: ReactNode = <div key="drop here">'Drop here'</div>;

Callers 1

SidebarFunction · 0.50

Calls 4

filterMethod · 0.65
hasMethod · 0.65
getTextMethod · 0.65
parseMethod · 0.45

Tested by

no test coverage detected