skip to Main Content

I want the data from the input to be output to the console when clicked, but for some reason they are output with every change in the ipnut – Reactjs

function Text() { const [text, setText] = useState(""); return ( <div className="white"> input from which I need to catch information <input type="text" placeholder="enter" onChange={(e) => setText(e.target.value)} /> <button onClick={console.log(text)}>CLICK</button> <div>{text}</div> </div> ); }

VIEW QUESTION
Back To Top
Search