1.0.3 • Published 1 year ago

@reactdev/react-use-toggle v1.0.3

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

react-use-toggle

Basically, what this hook does is that, it takes a parameter with value true or false and toggles that value to opposite. It's useful when we want to take some action into it's opposite action, for example: show and hide modal, show more/show less text, open/close side menu.

Usage

npm i @reactdev/react-use-toggle
import useToggle from "@reactdev/react-use-toggle";
function App() {
  // Call the hook which returns, current value and the toggler function

  const [isTextChanged, setIsTextChanged] = useToggle();

  return (
    <button onClick={setIsTextChanged}>
      {isTextChanged ? "Toggled" : "Click to Toggle"}
    </button>
  );
}
1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago