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

@reach/descendants

Package Overview
Dependencies
Maintainers
4
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@reach/descendants

A descendant index solution for better accessibility support in compound components

  • 0.12.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
108K
decreased by-56.61%
Maintainers
4
Weekly downloads
 
Created

What is @reach/descendants?

@reach/descendants is a utility for managing a list of descendants in a React component tree. It helps in scenarios where you need to keep track of a dynamic list of child components, such as in dropdowns, menus, or any other composite components.

What are @reach/descendants's main functionalities?

Managing Descendants

This feature allows you to manage a list of descendants within a component tree. The `useDescendants` hook provides the state and setter function for the descendants, while the `DescendantProvider` component makes this state available to the rest of the component tree.

import { useDescendants, DescendantProvider } from '@reach/descendants';

function MyComponent() {
  const [descendants, setDescendants] = useDescendants();

  return (
    <DescendantProvider descendants={descendants} setDescendants={setDescendants}>
      {/* Your component tree here */}
    </DescendantProvider>
  );
}

Registering Descendants

This feature allows individual components to register themselves as descendants. The `useDescendant` hook provides the index of the descendant and a `register` function to register the component's DOM node.

import { useDescendant } from '@reach/descendants';

function DescendantComponent() {
  const [index, register] = useDescendant();

  return (
    <div ref={register}>
      {/* Your descendant component content here */}
    </div>
  );
}

Other packages similar to @reach/descendants

FAQs

Package last updated on 26 Nov 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