how to submit form this Onchange? I don't have a button to fire the form, how to do that? I can't insert routes as it's a component for several clients. I use react hook forms
const handleChange = (e: any) => {
const avatar = URL.createObjectURL(e.target.files[0])
setAvatar(avatar)
};
Did you try this solution using useEffect
const [avatar,setAvatar] = useState(null);
useEffect(() => {
if(avatar) handleSubmit();
}, [avatar]);
const handleChange = (e: any) => {
const avatar = URL.createObjectURL(e.target.files[0])
setAvatar(avatar)
};
// suppose that this is this is your handleSubmit function
const handleSubmit = () => {
// your code goes here
};