-
-
Save epifanov-sergey/8ac420bfce99f4a4f681563acbce2cc6 to your computer and use it in GitHub Desktop.
640187-react-dropzone
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { createRef } from "react"; | |
import Dropzone from "react-dropzone"; | |
const dropzoneStyle = { | |
width: "200px", | |
height: "200px", | |
background: "red", | |
borderWidth: 2, | |
borderColor: "rgb(102, 102, 102)", | |
borderStyle: "dashed", | |
borderRadius: 5, | |
}; | |
withAttacher.propTypes = {}; // nothing is descending | |
export default function withAttacher(Component) { | |
return class extends React.Component { | |
constructor(props) { | |
super(props); | |
this.dropzoneRef = createRef(); | |
} | |
render() { | |
return ( | |
<Dropzone style={dropzoneStyle} ref={this.dropzoneRef} multiple={false}> | |
{({ getInputProps }) => ( | |
<React.Fragment> | |
<input {...getInputProps()} /> | |
<Component | |
{...this.props} | |
handleClick={() => { | |
this.dropzoneRef.current.open(); | |
}} | |
/> | |
</React.Fragment> | |
)} | |
</Dropzone> | |
); | |
} | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment