-
Notifications
You must be signed in to change notification settings - Fork 1
/
App.js
56 lines (51 loc) · 1.25 KB
/
App.js
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
45
46
47
48
49
50
51
52
53
54
55
56
import React, { Component } from 'react';
import ReactNative, {
Platform,
StyleSheet,
Text,
View,
requireNativeComponent,
TouchableOpacity,
UIManager
} from 'react-native';
export default class App extends Component<{}> {
render() {
return (
<View style={styles.container}>
<SwiftComponent
width={360}
height={180}
myText={'Initial Value'}
ref={(component) => this.mySwiftComponentInstance = component } />
<TouchableOpacity onPress={this.onButtonClick.bind(this)}>
<Text style={styles.button}>{'Update With Native Value'}</Text>
</TouchableOpacity>
</View>
);
}
onButtonClick(e) {
UIManager.dispatchViewManagerCommand(
ReactNative.findNodeHandle(this.mySwiftComponentInstance),
UIManager.SwiftComponent.Commands.updateValueViaManager,
[]
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
button: {
marginTop: 50,
width: 120,
height: 60,
borderRadius: 12,
borderWidth: 1,
borderColor: '#F0F',
backgroundColor: "#FFF"
}
});
const SwiftComponent = requireNativeComponent('SwiftComponent');