Skip to content

Instantly share code, notes, and snippets.

@reciosonny
Last active December 22, 2019 06:31
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save reciosonny/b3ef000c55ce6b1bb429bf775770fff2 to your computer and use it in GitHub Desktop.
componentHooks.js
function App() {
const [initialized, setInitialized] = useState(false);
const [clicked, setClicked] = useState(false);
useEffect(() => {
setInitialized(true);
});
return (
<div className="App">
{initialized && <h1>Initialized</h1>}
<h1 onClick={() => setClicked(true)}>Please click me!</h1>
{clicked && <h2>You clicked an object!</h2>}
</div>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment