Skip to content

Instantly share code, notes, and snippets.

@ericflo
Last active September 15, 2016 09:00
Show Gist options
  • Star 15 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ericflo/8431491 to your computer and use it in GitHub Desktop.
Save ericflo/8431491 to your computer and use it in GitHub Desktop.
ReactDropzone, a react component for interfacing with http://www.dropzonejs.com/
/** @jsx React.DOM */
var ReactDropzone = React.createClass({
componentDidMount: function() {
var options = {};
for (var opt in Dropzone.prototype.defaultOptions) {
var prop = this.props[opt];
if (prop) {
options[opt] = prop;
continue;
}
options[opt] = Dropzone.prototype.defaultOptions[opt];
}
this.dropzone = new Dropzone(this.getDOMNode(), options);
},
componentWillUnmount: function() {
this.dropzone.destroy();
this.dropzone = null;
},
render: function() {
var children = this.props.children;
return this.transferPropsTo(
<form>
{children ? <div className="fallback">{children}</div> : null}
</form>
);
}
});
@calbertts
Copy link

How did you manage the problem with the KEY (data-reactid) when you use a template for the file previews?.. I haven't been able to handle this problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment