import React, {useState} from 'react';

const AddItemForm = ({addItems}) => {
    const [currentText, setCurrentText] = useState("");

    const handleSubmit = (e) => {
        e.preventDefault();
        addItems(currentText);
        setCurrentText("");
    }

    return (
        <form onSubmit={handleSubmit}>
            <input type="text" value={currentText} onChange={(e) => setCurrentText(e.target.value)}></input>
            <input type="submit" value="Ajouter"></input>
        </form>
    );
}

export default AddItemForm;