Skip to content

Instantly share code, notes, and snippets.

@jogilvyt
Created June 20, 2022 09:50
Show Gist options
  • Save jogilvyt/5370acf68616d823aed426ed479f76f7 to your computer and use it in GitHub Desktop.
Save jogilvyt/5370acf68616d823aed426ed479f76f7 to your computer and use it in GitHub Desktop.
import React from "react";
const Toggle = () => {
const [isActive, setIsActive] = React.useState(false);
const toggleActiveState = activeState => () => {
setIsActive(activeState);
};
return (
<button onClick={toggleActiveState(!isActive)}>
{isActive ? "Active" : "Inactive"}
</button>
);
};
export default Toggle;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment