You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

use-sync-external-store

Package Overview
Dependencies
Maintainers
3
Versions
1265
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

use-sync-external-store

Backwards compatible shim for React's useSyncExternalStore. Works with any React that supports hooks.


Version published
Weekly downloads
7.8M
decreased by-17.55%
Maintainers
3
Created
Weekly downloads
 

Package description

What is use-sync-external-store?

The use-sync-external-store package provides a hook that allows React components to read from an external, synchronous data source and subscribe to updates from that source. It is designed to be a primitive hook for creating other hooks that need to subscribe to external data sources.

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

Subscribing to an external store

This feature allows you to create a custom hook that subscribes to an external store. The hook will re-render the component whenever the store updates.

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

function useCustomHook(store) {
  const state = useSyncExternalStore(
    store.subscribe,
    store.getSnapshot,
    store.getServerSnapshot
  );
  return state;
}

Other packages similar to use-sync-external-store

Readme

Source

use-sync-external-store

Backwards-compatible shim for React.useSyncExternalStore. Works with any React that supports Hooks.

See also https://github.com/reactwg/react-18/discussions/86.

FAQs

Package last updated on 10 Jul 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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc