Fomik does not validate field onPaste, unless you click outside of field (blur)
2 min readMay 29, 2023
Recently I had a nasty bug when using Formik with React and Next.JS.
When you added a contact from Android, a new value would be pasted into an input field. Unfortunately Formik did not realize that this was happening, and did not validate the field. We needed validation to run on paste.
tl;dr — my mega-hacky solution:
const handlePaste = () => {
setTimeout(() => {
emailRef.current.childNodes[1].firstChild.blur()…