Rehooks

Installation

Learn how to install Rehooks and get started with it.

Installation

To get started with Rehooks, you need to install the package using your preferred package manager. Here are the steps to install Rehooks:

Terminal
npm install rehooks-ts

You successfully installed Rehooks! Now you can start using the hooks in your project.

Usage

Once you have installed Rehooks, you can start using the hooks in your project. Here's an example of how to use the useCounter hook:

Component.tsx
import { useCounter } from "rehooks-ts";
 
function Component() {
  const { count, increment, decrement, reset, setCount } = useCounter(0);
 
  function multiply(value) {
    setCount((prev) => prev * value);
  }
 
  return (
    <>
      <p>Count: {count}</p>
      <button onClick={increment}>Increment</button>
      <button onClick={decrement}>Decrement</button>
      <button onClick={() => multiply(2)}>Multiply by 2</button>
      <button onClick={reset}>Reset</button>
    </>
  );
}

On this page