So I'm basically implementing my own error-text, if actionData.error occurs a red text pops up under the inputs and my error-text component goes invisible in 2 secs, but when i correctly fill the invalid fields then click post button again, error-texts appears like .5secs then goes invisible again then I navigate, i think after the first post request, actionData.errors stay the same until the request loading finish then re-render the page, i don't want it, how can I approach this?
blablabla, this is actionFunc
return json({
success: 'Your message has been sent successfully',
});
};
this is contact page
const Contact = () => {
const formData = useActionData<ActionData>();
const navigate = useNavigate();
console.log(formData);
useEffect(() => {
if (formData?.success) {
toast.success(formData.success);
setTimeout(() => {
// navigate('/');
}, 2250);
}
}, [formData, navigate]);
yeah it basically returns 3 times the same errors before resolving into json(message: 'successfully')