Created
April 16, 2024 00:27
-
-
Save madhoshyagnik/8d6378fa0c8e4681b6f43eed22b8a640 to your computer and use it in GitHub Desktop.
use state hook function to re-render react components
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useState } from "react"; | |
const Home = () => { | |
// let name = 'mario'; | |
const [name, setName] = useState('mario'); | |
const handleClick = (e) => { | |
setName('luiji'); | |
} | |
return ( | |
<div className="home"> | |
<h2>Homepage</h2> | |
<p>{name}</p> | |
<button onClick={handleClick}>Click me</button> | |
</div> | |
); | |
} | |
export default Home; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment