Files
react-native/local-cli/server/middleware/heapCapture/src/DropTarget.jsx
T
Charles DickandFacebook Github Bot 48d3cd7d26 Pull aggrow from facebookincubator/tracery-prerelease
Reviewed By: bnham

Differential Revision: D4250937

fbshipit-source-id: b5f2cfdeb06c04399670e463b8b2498e2fe0074b
2016-11-30 12:58:35 -08:00

34 lines
693 B
React

// @flow
import React from 'react';
type Props = {
id: string,
dropAction: (sourceId: string, thisId: string) => void,
children?: any,
}
export default class DropTarget extends React.Component {
props: Props;
_handleDragOver = (e: SyntheticDragEvent) => {
e.preventDefault();
}
_handleDrop = (e: SyntheticDragEvent) => {
const sourceId = e.dataTransfer.getData('text');
e.preventDefault();
this.props.dropAction(sourceId, this.props.id);
}
render(): React.Element<*> {
return React.cloneElement(
React.Children.only(this.props.children),
{
onDragOver: this._handleDragOver,
onDrop: this._handleDrop,
}
);
}
}