import React, { useRef } from 'react'
type props = {
    handleCreate: () => void
}
const TodoCreate = ({ handleCreate }: props) => {
    const inputref = useRef<React.InputHTMLAttributes | String>("")
    const handleSubmit = (e: React.ChangeEvent<HTMLInputElement>) => {
        e.preventDefault()
        // console.log(inputref.current.value)
        handleCreate({ name: inputref.current.value })
        inputref.current.value = ""
    }
    return (
        <>
            <div className='input-item'>
                <form onSubmit={handleSubmit}>
                    <input type='text' placeholder='Enter Item' required ref={inputref} />
                    <button type='submit'>Submit</button>
                </form>
            </div>
        </>
    )
}

export default TodoCreate