I'm using controlled Input with type file in React Component. If I selected one file in input component and toggling show/hide behavior of main component. On Component re-renders input is not working and throwing below error:
Uncaught DOMException: Failed to set the 'value' property on 'HTMLInputElement': This input element accepts a filename, which may only be programmatically set to the empty string.
const [filePath, setPath] = useState('');
<input
key={"a"}
id={"1"}
name={"file input"}
type="file"
value={filePath}
multiple
onChange={(event) =>
setPath(event.target.value)
}
/>