Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6214

TypeError: _fieldRef$current.blur is not a function

$
0
0

I used useRef& ref for a custom FieldInput component that contains <Input> from Native Base.

const fieldRef = useRef();...    const handleSubmitForm = (    values: FormValues,    helpers: FormikHelpers<FormValues>,  ) => { ....    fieldRef.current.blur();    helpers.resetForm();  };

However, I was getting an error on fieldRef.current that Object is possibly 'undefined'.. So, I changed it like this:

const fieldRef = useRef<any>(null);
fieldRef.current?.blur();

This fixed the inline error but upon submitting the form, I still get this:

Warning: An unhandled error was caught from submitForm() TypeError: _fieldRef$current.blur is not a function

How can I fix this? Any workaround would help. I just want to remove the warning.

codesandbox: https://snack.expo.io/@nhammad/jealous-beef-jerky-fix


Viewing all articles
Browse latest Browse all 6214

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>