import React from 'react';
import { StyleSheet, Text, View , Button } from 'react-native';
import Greeting from './components/Greeting'
export default class App extends React.Component {
constructor(props) {
super(props);
this.state = {
showText: '5566'
};
}
render() {
const setShowText = () => {
this.setState(preState=> {
return {
...this.state,
showText : preState.showText + '11'
}
})
}
return (
<View style={styles.container}>
<Text>{ this.state.showText }</Text>
<Button onPress={setShowText} title="press"></Button>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
2018年7月1日 星期日
[React Native]看著文件跌跌撞撞-State
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言