Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save madhoshyagnik/8d6378fa0c8e4681b6f43eed22b8a640 to your computer and use it in GitHub Desktop.
Save madhoshyagnik/8d6378fa0c8e4681b6f43eed22b8a640 to your computer and use it in GitHub Desktop.
use state hook function to re-render react components
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;
@madhoshyagnik
Copy link
Author

image

@madhoshyagnik
Copy link
Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment