Open EECOLOR opened 3 years ago
https://github.com/kaliberjs/forms/blob/b937d8769e9d8500a38f4b1a418d99d9a1eb40e7/src/components.js#L17
FormFieldValid is now implemented with useSnapshot which means it will render on keystrokes. We could add another hook that prevents these unneeded renders, something like this:
FormFieldValid
useSnapshot
function useFormFieldInvalid(field) { const [formFieldInvalid, setFormFieldInvalid] = React.useState(() => snapshot.get(field).invalid) React.useEffect( () => { setFormFieldInvalid(snapshot.get(field).invalid) return snapshot.subscribe(field, x => setFormFieldInvalid(x.invalid)) }, [field] ) return formFieldInvalid }
https://github.com/kaliberjs/forms/blob/b937d8769e9d8500a38f4b1a418d99d9a1eb40e7/src/components.js#L17
FormFieldValid
is now implemented withuseSnapshot
which means it will render on keystrokes. We could add another hook that prevents these unneeded renders, something like this: