addTodo.js 787 Bytes
Newer Older
YoonDongMin's avatar
YoonDongMin committed
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
import React, {useState} from 'react';
import {StyleSheet, Text,View, TextInput, Button} from 'react-native';

export default function AddTodo({submitHandler}) {
    const [text, setText] = useState('');

    const changeHandler = (val) => {
        setText(val);
    }

    return(
        <View>
            <TextInput
                style = {styles.input}
                placeholder = 'new todo...'
                onChangeText={changeHandler}
            />
            <Button onPress= {() =>submitHandler(text)} title = 'add todo' color = 'coral' />
        </View>
    )
}

const styles = StyleSheet.create({
    input: {
        marginBottom: 10,
        paddingHorizontal: 8,
        paddingVertical:6,
        borderBottomColor: '#ddd',
        borderBottomWidth: 1

    }
})