componentWillUnmount() { if (this.img) { this.cropper.destroy(); delete this.img; delete this.cropper; } }
componentWillReceiveProps(nextProps) { if (nextProps.newProfilePicture !== this.props.newProfilePicture) { this.cropper.destroy(); this.initCropper(); } }
componentDidUpdate() { this.cropper && this.cropper.destroy(); if (this.props.disableCrop) { return; } if (this.imageElement.current) { this.cropper = new Cropper(this.imageElement.current, { zoomable: false, scalable: false, cropBoxResizable: true, dragMode: "none", autoCropArea: 0.9, aspectRatio: this.props.width / this.props.height, }); } }
componentWillUnmount() { if (this.img) { this.cropper.destroy(); delete this.img; delete this.cropper; } }
componentWillReceiveProps(nextProps) { if (nextProps.newProfilePicture !== this.props.newProfilePicture) { this.cropper.destroy(); this.initCropper(); } }