Skip to content

Instantly share code, notes, and snippets.

@tpjnorton
Created October 23, 2020 09:29
Show Gist options
  • Save tpjnorton/c27bb2d9844217e0072bf641b61cdd37 to your computer and use it in GitHub Desktop.
Save tpjnorton/c27bb2d9844217e0072bf641b61cdd37 to your computer and use it in GitHub Desktop.
const Button = ({onClick, ...rest}) => {
const [loading, setLoading] = useState(false);
const onClicked = async () => {
setLoading(true);
await onClick();
setLoading(false);
}
return <button onClick={onClicked} {...rest}/>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment