score:3

Accepted answer
import React, { useState } from 'react';

function AddTodo({addTodo}) {

    const [content, setContent] = useState('');

    const handleChange = (e) => {
        setContent(e.target.value);
    }

    const handleSubmit = (e) => {
        e.preventDefault();
        addTodo(content);
    }

    return (
        <div>
            <form onSubmit={handleSubmit}>
                <label>Add new todo</label>
                <input type="text" onChange={handleChange}/>
            </form>
        </div>
    )
}

Related Query

More Query from same tag