From 371c1eb3f5060e0d8f90f52a9013d5bc92368dfa Mon Sep 17 00:00:00 2001 From: Rodri Sanchez Date: Mon, 11 Dec 2023 16:48:47 -0300 Subject: [PATCH] Add onLoad function to onClick --- src/components/UI/InputImage/InputImage.component.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components/UI/InputImage/InputImage.component.js b/src/components/UI/InputImage/InputImage.component.js index 9702e2ce5..75d5c33ed 100644 --- a/src/components/UI/InputImage/InputImage.component.js +++ b/src/components/UI/InputImage/InputImage.component.js @@ -37,10 +37,11 @@ class InputImage extends Component { /** * Callback fired when loading state changes */ - onLoad: PropTypes.func.isRequired, + onLoad: PropTypes.func.isRequired }; async resizeImage(file, imageName = null) { + const { onLoad } = this.props; //if you cancel the image uploaded, the event is dispached and the file is null try { const { onChange } = this.props; @@ -51,9 +52,12 @@ class InputImage extends Component { } catch (err) { console.error(err); } + onLoad(false); } onClick = async () => { + const { onLoad } = this.props; + onLoad(true); try { const imageURL = await window.cordova.plugins.safMediastore.selectFile(); const imageName = await window.cordova.plugins.safMediastore.getFileName( @@ -90,13 +94,12 @@ class InputImage extends Component { handleChange = async event => { const { onLoad } = this.props; - onLoad(true) + onLoad(true); const file = event.target.files[0]; if (file) { //if you cancel the image uploaded, the event is dispached and the file is null await this.resizeImage(file); } - onLoad(false) }; render() { const { intl } = this.props;