Many examples of this on here but can\'t seem to find any for react. I have managed to convert the vanilla js to react but getting an error.
The answer looks simple
-- Constructor
constructor(props) { super(props); this.state = { imgRef: "" }; }
-- Function
filePreview(e) { const file = e.target.files[0]; this.setState({ imgRef: URL.createObjectURL(file) }); }
-- Html