In my react component I have this type of code :
state = {
title: '',
file: ''
}
handleTextChange = (e) => {
this.setState({
[e.target.id] : e.target.value
})
}
handleFileChange = (e) => {
this.setState({
[e.target.id] : e.target.files[0]
})
}
render(){
return(
<input type="text" id="title" defaultValue={title} onBlur={this.handleTextChange}/>
<input type="file" id="file" onChange={this.handleFileChange}/>
)
}
Now the problem is when I change text, the selected file automatically deselect and I have to select again it. I have to do this thing every time when I change the text in textbox.
How can I set default value in the file the same as I can do in textbox so every time I do not have to select the same file.