Skip to content

Instantly share code, notes, and snippets.

@chuyihuang
Created August 29, 2017 08:12
Show Gist options
  • Save chuyihuang/212247f8bc1847d90ff5b3cca0105f21 to your computer and use it in GitHub Desktop.
Save chuyihuang/212247f8bc1847d90ff5b3cca0105f21 to your computer and use it in GitHub Desktop.
week_3_demo_1
import React, { Component } from 'react';
import { View, TextInput, Text, Button } from 'react-native';
export default class App extends Component {
constructor(props) {
super(props);
this.state = {
value: null
}
}
createTodo = () => {
alert(this.state.value);
}
render() {
console.log(this.state);
return (
<View style={{flex: 1, justifyContent: 'center', alignItems: 'center'}}>
<TextInput
style={{width: '80%', borderBottomWidth: 1, borderBottomColor: '#aaaaaa'}}
placeholder="輸入待做事項..."
value={this.state.value}
onChangeText={(value) => this.setState({value})}
/>
<Button title="送出" onPress={() => this.createTodo()} color="#c40000" />
</View>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment