I am trying to set focus on TextInput
when I click on edit button, but I am getting error.
Below is my code:
const MyProfileScreen = (props: any) => { const refsFocus = useRef(null); return (<><View><TextInput placeholder={'editable test'} placeholderTextColor={'red'} style={{color: 'red'}} ref={refsFocus} /></View><TouchableOpacity onPress={()=> { refsFocus.current.focus();} }><Text>Edit text input</Text></TouchableOpacity></> );};
But I am getting error on onPress={()=> { refsFocus.current.focus()} }
Error Message:
Object is possibly 'null'
const refsFocus: React.MutableRefObject<null>
I am not able to figure out what I am doing wrong