There is a one-page react application, one of the functions of which is drawing some graphs. There is a button to load user data about the color of the nodes in text form.
<Button style={{ margin: 6 }} variant="contained" color="primary" component="label" > Upload colors <input onChange={(e) => {this.uploadColors(e)}} style={{ display: 'none' }} type="file" /> </Button> And the processing function, I do not fully cite, is only a part connected with reading.
uploadColors = (e) => { let user_colors if (window.FileReader) { let file = e.target.files[0], reader = new FileReader(); reader.readAsText(file); reader.onload = function(r) { user_colors = reader.result //дальше что-то делаем с user_colors } }
If the user first loads the file, everything is fine Then he changes something in the application, say, the scale of graph drawing, and wants to load the same file again. The problem is that the same file does not load again. As I understand it, the fact is that onChange does not occur if the file is the same. It was thought to manually delete the information about the open file, but for some reason I did not find where the value is stored, on which the onChange response depends.