Closed fhbenatti closed 4 years ago
Hi @fhbenatti, can you provide the version of the library that using?
In the new version of the Unform library, can you use setError()
or setErrors()
method from the ref of form to display error. The unform-material-ui
components automatically display an error when using these methods. Check the Unform docs here.
Hi @italoiz Using setErrors method solve my problem. Thanks.
Hi,
I'm trying to use setErrors()
but it's not working as I expected 😬
Could you help me please?
Hi @guitexa,
To access the Unform methods you should use the useRef
variable on the <Form />
component, see docs.
In your example, you used in the <TextField />
component. In addition, you used the setErrors
incorrectly, see docs to manage errors correctly.
See an example I work well: https://stackblitz.com/edit/react-ts-j4qqx7
I appreciate your time to help me, I was using useRef
in wrong place, my mistake, I've fixed it, but I have the same typescript error Object is possibly 'null'
on line 9, as you can see here:
https://codesandbox.io/s/unform-material-ui-hm3bl
PS: This is a typescript error, I think you didn't see it in your project because you don't have typescript as dependency.
Edit: I already fix it by using FormHandles
typing and using ?
to set this is possible null.
Thank you so much for you patience for help me 🙏🏼
When 'error' attribute is set on TextField, the label don't be displayed in an error state