In my react component I have a file input:
`
and my onFileChan
onFileChan
The setState function is executed in asynchronous context.
setState
By the time the state is updated the e.target reference might or might not be gone.
e.target
const file = e.target.files[0]; can be used to "remember" the value as in your example.
const file = e.target.files[0];