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

Property 'blur' does not exist on type 'Input'

$
0
0

I am using the useRef hook to pass a ref property into my custom FieldInput component. This is then used for the validation of my form.

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

However, I get an error on fieldRef.current that Object is possibly 'undefined'.. In order to fix that, I made these changes:

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

However, I still get an error that Property 'blur' does not exist on type 'Input'.. Here, Input is imported from native-base. Due to this, I get type errors/warnings when I submit the form. An unhandled error was caught from submitForm()How can I get rid of these errors?

The full scenario is replicated here in a 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>