-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
53 lines (43 loc) · 951 Bytes
/
Copy pathApp.js
File metadata and controls
53 lines (43 loc) · 951 Bytes
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
import React from 'react';
import { StyleSheet, Text, View, Image } from 'react-native';
import Header from './src/Header';
import Input from './src/Input';
import List from './src/List';
export default class App extends React.Component {
state = {
todos: ['yemek yap']
}
constructor() {
super();
}
addItem(text) {
const { todos } = this.state
this.setState({todos: [...todos, text]})
}
removeItem = (index) => {
const {todos} = this.state
this.setState({
todos: todos.filter((todo,i)=> i!=index)
})
}
render() {
const {todos} = this.state
return (
<View style={styles.container}>
<Header>Yapılacaklar</Header>
<Input
onSubmitEditing={this.addItem.bind(this)}
/>
<List
list={todos}
onPressItem={this.removeItem}
/>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
backgroundColor: '#fff',
},
});