1
0
Code Issues Pull Requests Packages Projects Releases Wiki Activity GitHub Gitee
react-native-alipay/example/App.js

58 lines
1.3 KiB
JavaScript
Raw Normal View History

2020-07-07 17:44:10 +08:00
/**
* Sample React Native App
*
* adapted from App.js generated by the following command:
*
* react-native init example
*
* https://github.com/facebook/react-native
*/
import React, { Component } from 'react';
import { Platform, StyleSheet, Text, View } from 'react-native';
import Alipay from 'react-native-uiwjs-alipay';
export default class App extends Component<{}> {
state = {
status: 'starting',
message: '--'
};
componentDidMount() {
Alipay.sampleMethod('Testing', 123, (message) => {
this.setState({
status: 'native callback received',
message
});
});
}
render() {
return (
<View style={styles.container}>
<Text style={styles.welcome}>Alipay example</Text>
<Text style={styles.instructions}>STATUS: {this.state.status}</Text>
<Text style={styles.welcome}>NATIVE CALLBACK MESSAGE</Text>
<Text style={styles.instructions}>{this.state.message}</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
});