Use can use Ref object to focus the text input every time modal will be visible
check this code,,,,
export default function App() {
const [visible, setVisible] = React.useState(false);
const input = React.createRef();
React.useEffect(() => {
if (visible) {
input.current.focus();
}
}, [visible]);
return (
<View style={styles.container}>
<Button
title="Click"
onPress={() => {
setVisible(true);
}}
/>
<Modal
visible={visible}
onRequestClose={() => {
setVisible(false);
}}>
<View style={styles.modal}>
<TextInput ref={input} />
</View>
</Modal>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
paddingTop: Constants.statusBarHeight,
backgroundColor: '#ecf0f1',
padding: 8,
},
modal: {
width: '100%',
height: '100%',
},
});