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

@types/use-sync-external-store

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/use-sync-external-store

TypeScript definitions for use-sync-external-store

  • 0.0.4
  • ts4.3
  • ts4.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4M
decreased by-7.3%
Maintainers
1
Weekly downloads
 
Created

What is @types/use-sync-external-store?

The @types/use-sync-external-store package provides TypeScript type definitions for the useSyncExternalStore hook, which is a part of React's experimental API for subscribing to external stores. This hook allows you to synchronize your component's state with an external store without causing unnecessary re-renders, making it particularly useful for integrating non-React state management libraries with React components.

What are @types/use-sync-external-store's main functionalities?

Type-safe integration with external stores

This code demonstrates how to create a custom hook that uses useSyncExternalStore to subscribe to an external store. The hook takes a store object with subscribe and getState methods, subscribes to the store, and returns the current state. TypeScript types ensure the integration is type-safe.

import { useSyncExternalStore } from 'use-sync-external-store';

function useCustomStore(store) {
  const state = useSyncExternalStore(
    store.subscribe,
    store.getState
  );
  return state;
}

Other packages similar to @types/use-sync-external-store

FAQs

Package last updated on 30 Aug 2023

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