Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ahooks

Package Overview
Dependencies
Maintainers
5
Versions
111
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ahooks

react hooks library

  • 2.6.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
246K
increased by3.19%
Maintainers
5
Weekly downloads
 
Created

What is ahooks?

ahooks is a high-quality and reliable React Hooks library that provides a comprehensive set of hooks to enhance your React development experience. It includes a wide range of hooks for state management, side effects, lifecycle, and more.

What are ahooks's main functionalities?

State Management

The useBoolean hook provides a simple way to manage boolean state with additional methods to toggle, set true, and set false.

import { useBoolean } from 'ahooks';

function App() {
  const [state, { toggle, setTrue, setFalse }] = useBoolean(false);

  return (
    <div>
      <p>State: {state.toString()}</p>
      <button onClick={toggle}>Toggle</button>
      <button onClick={setTrue}>Set True</button>
      <button onClick={setFalse}>Set False</button>
    </div>
  );
}

Side Effects

The useDebounceEffect hook allows you to debounce side effects, which is useful for scenarios like search input where you want to delay the execution of a function.

import { useDebounceEffect } from 'ahooks';

function App() {
  const [value, setValue] = useState('');

  useDebounceEffect(() => {
    console.log('Debounced value:', value);
  }, [value], { wait: 500 });

  return (
    <input value={value} onChange={(e) => setValue(e.target.value)} />
  );
}

Lifecycle

The useMount hook runs a function once when the component is mounted, similar to componentDidMount in class components.

import { useMount } from 'ahooks';

function App() {
  useMount(() => {
    console.log('Component mounted');
  });

  return <div>Check the console</div>;
}

Other packages similar to ahooks

Keywords

FAQs

Package last updated on 08 Sep 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc