-
Notifications
You must be signed in to change notification settings - Fork 272
/
Copy pathTextInputEventPropagation.tsx
42 lines (38 loc) · 1.08 KB
/
TextInputEventPropagation.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import * as React from 'react';
import { StyleSheet, SafeAreaView, TextInput, Pressable } from 'react-native';
import { nativeEventLogger } from '../utils/helpers';
export function TextInputEventPropagation() {
const [value, setValue] = React.useState('');
const handleChangeText = (value: string) => {
setValue(value);
console.log(`Event: changeText`, value);
};
return (
<SafeAreaView style={styles.container}>
<Pressable onPress={nativeEventLogger('Pressable.press')}>
<TextInput
style={styles.textInput}
value={value}
editable={true}
onChangeText={handleChangeText}
onChange={nativeEventLogger('TextInput.change')}
onPressIn={nativeEventLogger('TextInput.pressIn')}
onPressOut={nativeEventLogger('TextInput.pressOut')}
/>
</Pressable>
</SafeAreaView>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
textInput: {
backgroundColor: 'white',
margin: 20,
padding: 8,
fontSize: 18,
borderWidth: 1,
borderColor: 'grey',
},
});