Skip to content

Instantly share code, notes, and snippets.

@Killavus
Last active August 29, 2015 14:25
Show Gist options
  • Save Killavus/c1b13026902b28fba19b to your computer and use it in GitHub Desktop.
Save Killavus/c1b13026902b28fba19b to your computer and use it in GitHub Desktop.
import React from 'react/addons';
import { DragDropContext, DragSource } from 'react-dnd';
import HTML5Backend from 'react-dnd/modules/backends/HTML5';
@DragDropContext(HTML5Backend)
class App extends React.Component {
render() {
return(
<div>
{this.props.children}
</div>
);
}
}
const FooSource = {
beginDrag() { return {}; }
};
function collectFooSource(connect) {
return {
connectAsDragSource: connect.dragSource()
};
}
@DragSource("foo", FooSource, collectFooSource)
class Foo extends React.Component {
render() {
let { connectAsDragSource } = this.props;
return connectAsDragSource(<p>Test!</p>);
}
}
React.render(<App><Foo key='1' /><Foo key='2' /></App>, document.body); // Error!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment