Reactjs – Can't access state when pressing key
import { useState, useRef, useEffect } from "react"; function App() { const [message, setMessage] = useState(""); const inpt = useRef(); const handleKeyDown = (e) => { if (e.key === "Enter") { handleClick(); } }; useEffect(() => { inpt.current.addEventListener("keydown", handleKeyDown); return…