diff --git a/package.json b/package.json index b29aa43..02085c8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "openstack-uicore-foundation", - "version": "4.2.22", + "version": "4.2.23-beta.2", "description": "ui reactjs components for openstack marketing site", "main": "lib/openstack-uicore-foundation.js", "scripts": { diff --git a/src/components/inputs/upload-input-v2/dropzone.js b/src/components/inputs/upload-input-v2/dropzone.js index 27973c5..3492042 100644 --- a/src/components/inputs/upload-input-v2/dropzone.js +++ b/src/components/inputs/upload-input-v2/dropzone.js @@ -1,5 +1,4 @@ import React from 'react' -import ReactDOM from 'react-dom' import extend from 'extend' import 'dropzone/dist/dropzone.css'; import {Icon} from './icon' @@ -15,6 +14,7 @@ export class DropzoneJS extends React.Component { constructor(props) { super(props); + this.dropzoneRef = React.createRef(); this.state = {files: []}; this.onUploadComplete = this.onUploadComplete.bind(this); this.onError = this.onError.bind(this); @@ -78,6 +78,7 @@ export class DropzoneJS extends React.Component { * Sets up dropzone.js with the component. */ componentDidMount () { + if(!this.dropzoneRef.current) return; const options = this.getDjsConfig(); Dropzone = Dropzone || require('dropzone'); @@ -87,9 +88,10 @@ export class DropzoneJS extends React.Component { console.info('Neither postUrl nor a "drop" eventHandler specified, the React-Dropzone component might misbehave.') } - var dropzoneNode = this.props.config.dropzoneSelector || ReactDOM.findDOMNode(this); - this.dropzone = new Dropzone(dropzoneNode, options); + const dropzoneNode = this.dropzoneRef.current; + if (!dropzoneNode) throw new Error("Dropzone node not found"); + this.dropzone = new Dropzone(dropzoneNode, options); this.setupEvents() } @@ -134,8 +136,10 @@ export class DropzoneJS extends React.Component { this.queueDestroy = false; if (!this.dropzone) { - const dropzoneNode = this.props.config.dropzoneSelector || ReactDOM.findDOMNode(this); + const dropzoneNode = this.dropzoneRef.current; + if (!dropzoneNode) throw new Error("Dropzone node not found"); this.dropzone = new Dropzone(dropzoneNode, this.getDjsConfig()); + this.setupEvents(); } this.dropzone.options = extend(true, {}, this.dropzone.options, djsConfigObj, postUrlConfigObj); @@ -158,14 +162,14 @@ export class DropzoneJS extends React.Component { if (!this.props.config.postUrl && this.props.action) { return ( -
); } else { return ( -