Get file name from file input and save it into state. You might need to use this when you hide your html file input and use button or some other element to trigger the click on the file input.
Source code viewer
import React from 'react'; import ReactDOM from 'react-dom'; class MyComponent extends React.PureComponent { constructor(props) { super(props); this.state = { fileName: '', }; } render() { return <> <span>{this.state.fileName}</span><br /> <input type="file" onChange={(e) => { e.preventDefault(); this.setState({ fileName: e.target.files[0].name }); }} /> </>; } }Programming Language: ECMAScript