Skip to content

Instantly share code, notes, and snippets.

@ianks
Last active November 10, 2020 21:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ianks/5eff3163dcc433bf5ae7386877407954 to your computer and use it in GitHub Desktop.
Save ianks/5eff3163dcc433bf5ae7386877407954 to your computer and use it in GitHub Desktop.
export const UserAvatar = () => {
const [isHidden, setHidden] = React.useState(false);
// Will instantly hide the component, causing a jarring UX
if (isHidden) {
return null;
}
return (
<>
<img src="https://some.png" />
<button onClick={() => setHidden(!isHidden)}>Toggle me!</button>
</>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment