Created
August 29, 2017 08:12
-
-
Save chuyihuang/212247f8bc1847d90ff5b3cca0105f21 to your computer and use it in GitHub Desktop.
week_3_demo_1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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