Enhance photo upload functionality in ArticleQuestionForm and ArticleRatingForm: Added reset method to PhotoUpload component and integrated it into both forms to clear uploaded files upon submission. Improved user experience by ensuring the photo upload state resets after form submission.
This commit is contained in:
@@ -153,6 +153,20 @@ class PhotoUpload extends Component {
|
||||
img.src = dataURL;
|
||||
};
|
||||
|
||||
// Method to reset the component
|
||||
reset = () => {
|
||||
this.setState({
|
||||
files: [],
|
||||
previews: [],
|
||||
error: null
|
||||
});
|
||||
|
||||
// Also reset the file input
|
||||
if (this.fileInputRef.current) {
|
||||
this.fileInputRef.current.value = '';
|
||||
}
|
||||
};
|
||||
|
||||
render() {
|
||||
const { files, previews, error } = this.state;
|
||||
const { disabled, label } = this.props;
|
||||
|
||||
Reference in New Issue
Block a user