Remove state from components/ReadFileDropContainer

main
Mike Fix 7 years ago
parent d819727285
commit 606e150ed7

@ -14,27 +14,10 @@ const spec = {
const collect = (connect, monitor) => ({ connectDropTarget: connect.dropTarget(), isOver: monitor.isOver() }) const collect = (connect, monitor) => ({ connectDropTarget: connect.dropTarget(), isOver: monitor.isOver() })
class ReadFileDropContainer extends React.Component { const ReadFileDropContainer = props => props.connectDropTarget(
constructor(props) {
super(props)
this.state = { isFileOver: false }
}
componentWillReceiveProps(nextProps) {
if (!this.props.isOver && nextProps.isOver) {
this.setState({ isFileOver: true })
}
if (this.props.isOver && !nextProps.isOver) {
this.setState({ isFileOver: false })
}
}
render() {
const content = (
<div className="dnd-container"> <div className="dnd-container">
{ this.state.isFileOver ? <div className="dnd-overlay">Drop your file here to import</div> : null } { props.isOver ? <div className="dnd-overlay">Drop your file here to import</div> : null }
{ this.props.children } {props.children}
<style jsx>{` <style jsx>{`
.dnd-container { .dnd-container {
position: relative; position: relative;
@ -57,8 +40,4 @@ class ReadFileDropContainer extends React.Component {
</div> </div>
) )
return this.props.connectDropTarget(content)
}
}
export default DropTarget(NativeTypes.FILE, spec, collect)(ReadFileDropContainer) export default DropTarget(NativeTypes.FILE, spec, collect)(ReadFileDropContainer)

Loading…
Cancel
Save