Consider the following code in React:
// rendered:
<input type="file" onChange={onFileSelected} />
// Event handler:
function onFileSelected(event: ChangeEvent<HTMLInputElement>) {
console.log('event:');
console.log(event);
console.log('event.currentTarget.files:');
console.log(event.currentTarget.files);
}
Now after selecting a file on my onFileSelected
function is triggered, this is the output:
I marked my confusion in the screenshot:
event.currentTarget
is null, but event.currentTarget.files
is accessible? How is that possible?