In my react component I have a file input:
`
and my onFileChan
Very simple/basic example to do the same task:
class Hello extends React.Component {
constructor(props) {
super(props);
this.state = {
file: ''
};
}
render() {
return
{
this.setState({file: e.target.files[0]}, () => {
console.log('state', this.state);
})
}} />
;
}
}
ReactDOM.render(
,
document.getElementById('container')
);
I have added console log when the state will be set it will log the file details. You can see in the log when you select a file the state includes the file data.
To see the console log you need to right click and inspect and see the Console.
Checkout working example here https://jsfiddle.net/1oj3h417/2/
Let me know if you have any doubt