import React , {useState} from "react";
import ReactDOM from 'react-dom';
const App = () => {
const [disp,setDisp] = useState(1);
let nam;
function prin() {
setDisp(nam);
}
return(
<>
<h1>Hello {disp}</h1>
<input type="text" placeholder="Enter Your Name" value={nam}/>
<button onClick={prin}> Click Me !</button>
</>
)
};
export default App;
There's some problem with the prin() function. I am a beginner trying to learn ReactJS Hooks. Please help me with the bug in the code and the concepts involved here. The goal of the program is to display the name after "Hello" after the button is clicked.