-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
44 lines (38 loc) · 1.04 KB
/
App.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
43
44
import React, {useRef} from 'react';
import {View, TouchableOpacity, StyleSheet, Text} from 'react-native';
import ModalComponent, {ModalRef} from './src/modal/ModalComponent';
export type ExampleData = {
message: string;
};
const App: React.FC = () => {
const modalRef = useRef<ModalRef>(null);
const handleOpenModal = () => {
// You can pass any data to the `openModal` function.
const dataToPass: ExampleData = {message: 'Hello from Parent!'};
modalRef.current?.openModal(dataToPass);
};
return (
<View>
<ModalComponent ref={modalRef} />
<TouchableOpacity style={styles.button} onPress={handleOpenModal}>
<Text style={styles.buttonText}>{'Open Modal'}</Text>
</TouchableOpacity>
</View>
);
};
const styles = StyleSheet.create({
button: {
height: 45,
width: 250,
marginTop: 35,
borderRadius: 16,
backgroundColor: 'purple',
alignSelf: 'center',
alignItems: 'center',
justifyContent: 'center',
},
buttonText: {
color: '#fff',
},
});
export default App;