DEV Community

Discussion on: ⛓ Uncontrolled form validation with React

Collapse
 
napcoder profile image
Marco Travaglini

Hi Bill, as far as I know you can still attach the "onChange", "onBlur", etc.. to uncontrolled component, no need to use plain events. The key is not to use the "value" prop, so the DOM component can rely on its internal state.

Also, I'm facing with a React bug, where controlled components loose the cursor position: using the uncontrolled component is a good way to avoid this bug, but then I'm not sure how to validate the input: do you have any suggestion?

Collapse
 
bluebill1049 profile image
Bill

Have you tried with this custom hook which I have built? react-hook-form.com/ it may have answer to your question.