-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbody.js
59 lines (45 loc) · 1.29 KB
/
body.js
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
54
55
56
57
58
59
import React,{useState} from 'react'
import {View,Button,Text,StyleSheet,TextInput, FlatList} from 'react-native'
import Lists from './lists'
export default function body(){
const [todos,setTodo]=useState([
{id:'0',title:'do walk'},
{id:'1',title:'go work'}
])
const [name,setName]=useState('')
return(
<View style={Styles.bodybox} >
<TextInput style={Styles.input} placeholder='enter the name' value={name} onChangeText={ (text) => setName(text) } />
<Button title="submit" color="orange"
onPress={ ()=> (
setTodo([...todos,
{
id:todos.length,
title:name
}]
),
setName('')
) } />
<FlatList
keyExtractor={(item) =>(item.id.toString())}
data={todos}
renderItem={({ item }) => (
<Lists item={item} />
)}
/>
</View>
)
}
const Styles = StyleSheet.create({
bodybox:{
padding:40,
},
input:{
marginTop:100,
padding:1,
margin:10,
borderBottomWidth:1,
textAlign:"center",
borderColor:'grey',
}
})