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

@react-hookz/web

Package Overview
Dependencies
Maintainers
2
Versions
128
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@react-hookz/web

React hooks done right, for browser and SSR.

  • 24.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
190K
increased by21.37%
Maintainers
2
Weekly downloads
 
Created

What is @react-hookz/web?

@react-hookz/web is a collection of React hooks designed to simplify common web development tasks. It provides a wide range of hooks for state management, side effects, DOM interactions, and more, making it easier to build complex web applications with React.

What are @react-hookz/web's main functionalities?

State Management

The useToggle hook provides a simple way to manage boolean state. It returns the current state and a function to toggle the state.

import { useToggle } from '@react-hookz/web';

function ToggleComponent() {
  const [value, toggle] = useToggle();

  return (
    <div>
      <p>{value ? 'ON' : 'OFF'}</p>
      <button onClick={toggle}>Toggle</button>
    </div>
  );
}

Side Effects

The useDebounce hook delays the update of a value until after a specified delay. This is useful for scenarios like search input where you want to wait for the user to stop typing before performing an action.

import { useDebounce } from '@react-hookz/web';

function SearchComponent() {
  const [query, setQuery] = useState('');
  const debouncedQuery = useDebounce(query, 500);

  useEffect(() => {
    if (debouncedQuery) {
      // Perform search
    }
  }, [debouncedQuery]);

  return (
    <input
      type="text"
      value={query}
      onChange={(e) => setQuery(e.target.value)}
    />
  );
}

DOM Interactions

The useEventListener hook allows you to easily add and clean up event listeners. In this example, a click event listener is added to the window object.

import { useEventListener } from '@react-hookz/web';

function ClickLogger() {
  useEventListener(window, 'click', () => {
    console.log('Window clicked');
  });

  return <div>Click anywhere to log a message</div>;
}

Other packages similar to @react-hookz/web

Keywords

FAQs

Package last updated on 04 Feb 2024

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