Add DraggableNode component

This commit is contained in:
2018-04-07 14:06:35 +05:30
parent e6a37a507d
commit 9a7e983e9a
2 changed files with 26 additions and 0 deletions
@@ -0,0 +1,25 @@
import * as React from 'react';
interface OnClickProps {
onClick(event: React.MouseEvent<HTMLDivElement>): void;
}
export class DraggableNode extends React.Component {
getModifiedChildrenWithAddedClickHandler(): React.ReactElement<OnClickProps>[] {
return React.Children.map(this.props.children, (eachChild) => {
// tslint:disable-next-line:no-console
return React.cloneElement(
eachChild as React.ReactElement<OnClickProps>,
{
onClick: function (event: React.MouseEvent<HTMLDivElement>) {
// tslint:disable-next-line:no-console
console.log(arguments);
}
});
});
}
render() {
return this.getModifiedChildrenWithAddedClickHandler();
}
}
+1
View File
@@ -0,0 +1 @@
export { DraggableNode } from './DraggableNode';