use state other than form state within useActionState
Unanswered
Pollock posted this in #help-forum
PollockOP
I am working on contact us form which gets submitted when captcha validates.
const [captcha, setCaptcha] = useState('');
const [state, action, pending] = useActionState(contactus, undefined)
useEffect(() => {
setCaptcha(captchaGenerator());
}, []);
i have generated captcha text and set it to a state named captcha.
Also, i have a state and action for form from useActionState.
Now when form gets submitted i need to validate user submitted captcha (maintained in form state) with captcha state. I am unable to access captcha state in form action which gets only args previous state and formData for this submission.
How can i validate captcha in form action?
const [captcha, setCaptcha] = useState('');
const [state, action, pending] = useActionState(contactus, undefined)
useEffect(() => {
setCaptcha(captchaGenerator());
}, []);
i have generated captcha text and set it to a state named captcha.
Also, i have a state and action for form from useActionState.
Now when form gets submitted i need to validate user submitted captcha (maintained in form state) with captcha state. I am unable to access captcha state in form action which gets only args previous state and formData for this submission.
How can i validate captcha in form action?