import { useEffect, useRef, useState } from "react"; const initialState = { question: "", answer: "" }; export function EntryForm({ onSubmit, onCancel, initialValue, saving }) { const [form, setForm] = useState(initialState); const formRef = useRef(null); useEffect(() => { setForm(initialValue || initialState); if (formRef.current) { formRef.current.scrollIntoView({ behavior: "smooth", block: "start" }); formRef.current.querySelector("input")?.focus(); } }, [initialValue]); return (
); }